Skip to content

Clean up atomicModifyIORef stuff

Summary

Back when I replaced the primop supporting atomicModifyIORef, the decision was made (I think in consultation with @bgamari, but I'm not sure) to use atomicModifyIORef2 rather than atomicModifyIORef2Lazy to implement atomicModifyIORef. I believed then and I believe now that that was a good decision, but it was a semantic change and the documentation was never updated to reflect it. There's also a useless and confusing lazy pattern match in the definition of atomicModifyIORef that should be removed. And there's a curious duplication between atomicModifyIORef and atomicModifyIORefP

Proposed improvements or changes

Change the documentation of atomicModifyIORef to reflect this change, and document when it occurred. In particular, the example it claims will leak memory actually won't anymore. Explain that the pair is forced, but not its components.

Move the implementation of atomicModifyIORef into GHC.IORef and delete atomicModifyIORefP.

Remove the (useless) lazy pattern match in atomicModifyIORef. It's useless because atomicModifyIORef2 already forces that pair.

Environment

  • GHC version used (if appropriate):
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information