IORef
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
A carrier for
Accum effects. This carrier performs its append
operations strictly and thus avoids the space leaks inherent in lazy
writer monads. These appends are left-associative; as such,
[] is a poor choice of monoid for computations that entail
many calls to
add. The
Seq or
DList monoids may
be a superior choice. This carrier also uses an
IORef to store
its accumulator, which allows it a
MonadUnliftIO instance, but
precludes backtracking when run in conjunction with
NonDet.
A carrier for the
State effect. It uses an
IORef
internally to handle its state, and thus admits a
MonadUnliftIO
instance. Because the state operations are performed impurely, this
carrier will not lose state effects even with nefarious uses of
liftWith.
Unlike the other carriers for
State, this carrier's effects
will not backtrack when run in conjuction with
NonDet effects.
Lifted reexports from
IORef module.
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.
Lifted
Data.IORef.
Note: it requires
Prim because
MutVar from the
primitive library is a generalization of
IORef.
Mutable references in the IO monad.
A strict (WHNF) variant of
IORef.