Portability | portable |
---|---|

Stability | experimental |

Maintainer | alexey.skladnoy@gmail.com |

Safe Haskell | None |

Mutable references in monads which are instances of `MonadPrim`

.

- data PrimRef m a
- newPrimRef :: PrimMonad m => a -> m (PrimRef m a)
- readPrimRef :: PrimMonad m => PrimRef m a -> m a
- writePrimRef :: PrimMonad m => PrimRef m a -> a -> m ()
- modifyPrimRef :: PrimMonad m => PrimRef m a -> (a -> a) -> m ()
- modifyPrimRef' :: PrimMonad m => PrimRef m a -> (a -> a) -> m ()

# PrimRefs

newPrimRef :: PrimMonad m => a -> m (PrimRef m a)Source

Create new mutable variable with initial value `a`

.

readPrimRef :: PrimMonad m => PrimRef m a -> m aSource

Read value of `PrimRef`

.

writePrimRef :: PrimMonad m => PrimRef m a -> a -> m ()Source

Write value to `PrimRef`

.

modifyPrimRef :: PrimMonad m => PrimRef m a -> (a -> a) -> m ()Source

Modify content of `PrimRef`

using function.

modifyPrimRef' :: PrimMonad m => PrimRef m a -> (a -> a) -> m ()Source

Modify content of `PrimRef`

using function and evaluate result of
function application to WHNF before storing it in the variable.