atomic-modify-general: Generalizations of atomicModifyIORef

[ bsd2, concurrency, library ] [ Propose Tags ]

base provides

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

to modify the value in an IORef and return a result (and, in the case of atomicModifyIORef2, also return the old value).

In Data.IORef.AtomicModify, we generalize this from pairs to arbitrary types for which the user can provide a function to extract the new value to store in the IORef.

In Data.IORef.AtomicModify.Generic, we offer a faster but more restricted version taking advantage of the fact that the primop used to implement atomicModifyIORef2 actually works for somewhat more general record types than atomicModifyIORef2 accepts.


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
Dependencies base (>=4.11 && <4.19), primitive [details]
License BSD-2-Clause
Copyright 2023 David Feuer
Author David Feuer
Category Concurrency
Home page
Source repo head: git clone
Uploaded by dfeuer at 2023-03-10T01:50:25Z
Distributions NixOS:
Downloads 68 total (5 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-03-10 [all 1 reports]