In the process of replacing atomicModifyMutVar#, I noticed that atomicModifyIORef' is just a little bit lazy:
atomicModifyIORef' ref (\x -> (x + 1, undefined))
will increment the reference and then throw an exception in the calling thread. We could sometimes avoid creating thunks by changing this, so the above would install undefined in the IORef as well. For example, suppose I write
atomicModifyIORef' ref (\x -> (3, x + 5))
This will end up producing a thunk for the second component. That could be avoided using something like
atomicModifyIORef' ref (\ !x -> (3, x + 5))
but it seems a little surprising to have to do that in a function that focuses on being strict.
I don't really care too much one way or the other, but I figured I should point this out and see what you all think.