[Haskell-cafe] ANN: atomic-modify-general
David Feuer
david.feuer at gmail.com
Fri Mar 10 02:01:01 UTC 2023
I just put together a new package, atomic-modify-general, for
generalizations of the `atomicModifyIORef` operation. In particular:
1. Versions that allow a result of an arbitrary type (not necessarily
a pair), where the caller passes in an extraction function. These work
with `Array` and `SmallArray` from `primitive` as well as `IORef`.
2. A version that works with record types (not just pairs) whose first
field is the new value to install in the `IORef`. This uses
implementation details of the `atomicModifyMutVar#` primop as well as
GHC's heap object layout to achieve better performance.
Please try it out and let me know how it goes, and what extras you may want!
Hackage: https://hackage.haskell.org/package/atomic-modify-general-0.1.0.0
More information about the Haskell-Cafe
mailing list