Proposal: Add atomic IORef operations to Data.IORef

David Feuer david.feuer at gmail.com
Fri Jan 15 20:36:11 UTC 2021


Please do feel free to suggest a better name. I would certainly have
named it better had I been able to think of one.

On Fri, Jan 15, 2021 at 3:33 PM <olivercharles at fastmail.com> wrote:
>
> I would suggest better naming that suffixing with '2', if the suggestion was to add them with the same names as GHC.IORef
> On 15 Jan 2021, 20:05 +0000, David Feuer <david.feuer at 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 at haskell.org
>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list