+1 with sufficient documentation

On Fri, Jan 15, 2021, 14:06 David Feuer <david.feuer@gmail.com> wrote:
GHC.IORef currently exports

atomicModifyIORef2 :: IORef a -> (a -> (a,b)) -> IO (a, (a, b))
atomicSwapIORef :: IORef a -> a -> IO a

atomicModifyIORef2 is a lot like atomicModifyIORef, but it returns
both the old value in the IORef and the full result of applying the
user-supplied function to that. This is a pretty thin wrapper around
the newish atomicModifyMutVar2# primop, which has replaced the less
powerful atomicModifyMutVar#.

atomicSwapIORef atomically installs a user-supplied value in an IORef
and returns the old value. It is currently implemented using
atomicModifyIORef2, but it can and should be reimplemented using its
own, more efficient primop.

I propose to add both of these functions to Data.IORef.

David
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries