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.
The IORef type
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.
Unlifted Data.IORef.
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 Data.IORef module.
Lifted reexports from IORef module.
An IORef holds a single Unbox-able value.
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.
The IORef type
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.