monad-primitive-0.1: Type class for monad transformers stack with pirimitive base monad.

Copyright(c) 2013 Aleksey Khudyakov
LicenseBSD3
Maintaineralexey.skladnoy@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.PrimRef

Contents

Description

Mutable references in monads which are instances of MonadPrim.

Synopsis

PrimRefs

data PrimRef m a #

Mutable variable which full analog of IORef or STRef but could use either of the monads. Unfortunately there's no way to convert PrimRef to STRef or IORef.

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

Create new mutable variable with initial value a.

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

Read value of PrimRef.

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

Write value to PrimRef.

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

Modify content of PrimRef using function.

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

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