<div dir="auto">+1 with sufficient documentation</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 15, 2021, 14:06 David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">GHC.IORef currently exports<br>
<br>
atomicModifyIORef2 :: IORef a -> (a -> (a,b)) -> IO (a, (a, b))<br>
atomicSwapIORef :: IORef a -> a -> IO a<br>
<br>
atomicModifyIORef2 is a lot like atomicModifyIORef, but it returns<br>
both the old value in the IORef and the full result of applying the<br>
user-supplied function to that. This is a pretty thin wrapper around<br>
the newish atomicModifyMutVar2# primop, which has replaced the less<br>
powerful atomicModifyMutVar#.<br>
<br>
atomicSwapIORef atomically installs a user-supplied value in an IORef<br>
and returns the old value. It is currently implemented using<br>
atomicModifyIORef2, but it can and should be reimplemented using its<br>
own, more efficient primop.<br>
<br>
I propose to add both of these functions to Data.IORef.<br>
<br>
David<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>