IORef -package:fused-effects
Mutable references in the IO monad.
A mutable variable in the
IO monad.
>>> import GHC.Internal.Data.IORef
>>> r <- newIORef 0
>>> readIORef r
0
>>> writeIORef r 1
>>> readIORef r
1
>>> atomicWriteIORef r 2
>>> readIORef r
2
>>> modifyIORef' r (+ 1)
>>> readIORef r
3
>>> atomicModifyIORef' r (\a -> (a + 1, ()))
>>> readIORef r
4
See also
STRef and
MVar.
A mutable variable in the
IO monad.
>>> import GHC.Internal.Data.IORef
>>> r <- newIORef 0
>>> readIORef r
0
>>> writeIORef r 1
>>> readIORef r
1
>>> atomicWriteIORef r 2
>>> readIORef r
2
>>> modifyIORef' r (+ 1)
>>> readIORef r
3
>>> atomicModifyIORef' r (\a -> (a + 1, ()))
>>> readIORef r
4
See also
STRef and
MVar.
A mutable variable in the
IO monad.
>>> import Data.IORef
>>> r <- newIORef 0
>>> readIORef r
0
>>> writeIORef r 1
>>> readIORef r
1
>>> atomicWriteIORef r 2
>>> readIORef r
2
>>> modifyIORef' r (+ 1)
>>> readIORef r
3
>>> atomicModifyIORef' r (\a -> (a + 1, ()))
>>> readIORef r
4
See also
STRef and
MVar.
A mutable variable in the
IO monad
Lifted reexports from
IORef module.
A mutable variable in the
IO monad.
>>> import Data.IORef
>>> r <- newIORef 0
>>> readIORef r
0
>>> writeIORef r 1
>>> readIORef r
1
>>> atomicWriteIORef r 2
>>> readIORef r
2
>>> modifyIORef' r (+ 1)
>>> readIORef r
3
>>> atomicModifyIORef' r (\a -> (a + 1, ()))
>>> readIORef r
4
See also
STRef and
MVar.
Utilities for Data.IORef.
Mutable references in a concurrency monad.
Deviations: There is no Eq instance for
MonadConc the IORef type. Furthermore, the
mkWeakIORef function is not provided.
Mutable references in the IO monad.
Lifted
Data.IORef.
Note: it requires
Prim because
MutVar from the
primitive library is a generalization of
IORef.
A strict (WHNF) variant of
IORef.
Every IORef has a unique identifier.