IORef package:concurrency

Mutable references in a concurrency monad. Deviations: There is no Eq instance for MonadConc the IORef type. Furthermore, the mkWeakIORef function is not provided.
Atomically modify the value stored in a reference. This imposes a full memory barrier.
Strict version of atomicModifyIORef. This forces both the value stored in the IORef as well as the value returned.
Replace the value stored in a reference, with the barrier-to-reordering property that atomicModifyIORef has.
atomicWriteIORef r a = atomicModifyIORef r $ const (a, ())
Mutate the contents of a IORef. Be warned that modifyIORef does not apply the function strictly. This means if the program calls modifyIORef many times, but seldomly uses the value, thunks will pile up in memory resulting in a space leak. This is a common mistake made when using a IORef as a counter. For example, the following will likely produce a stack overflow:
ref <- newIORef 0
replicateM_ 1000000 $ modifyIORef ref (+1)
readIORef ref >>= print
To avoid this problem, use modifyIORef' instead.
Strict version of modifyIORef
Create a new reference.
newIORef = newIORefN ""
Read the current value stored in a reference.
readIORef ioref = readForCAS ioref >>= peekTicket
Write a new value into an IORef, without imposing a memory barrier. This means that relaxed memory effects can be observed.
Perform a machine-level compare-and-swap (CAS) operation on a IORef. Returns an indication of success and a Ticket for the most current value in the IORef. This is strict in the "new" value argument.
A replacement for atomicModifyIORef using a compare-and-swap. This is strict in the "new" value argument.
A variant of modifyIORefCAS which doesn't return a result.
modifyIORefCAS_ ioref f = modifyIORefCAS ioref (\a -> (f a, ()))
Create a new reference, but it is given a name which may be used to present more useful debugging information.
newIORefN _ = newIORef