Copyright | (c) Harvard University 2006-2011 (c) Geoffrey Mainland 2011-2014 |
---|---|
License | BSD-style |
Maintainer | Geoffrey Mainland <mainland@cs.drexel.edu> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell98 |
- class Monad m => MonadRef r m | m -> r where
- newRef :: a -> m (r a)
- readRef :: r a -> m a
- writeRef :: r a -> a -> m ()
- modifyRef :: r a -> (a -> a) -> m ()
- modifyRef' :: r a -> (a -> a) -> m ()
- class MonadRef r m => MonadAtomicRef r m | m -> r where
- atomicModifyRef :: r a -> (a -> (a, b)) -> m b
- atomicModifyRef' :: r a -> (a -> (a, b)) -> m b
Documentation
class Monad m => MonadRef r m | m -> r where Source
The MonadRef
type class abstracts over the details of manipulating
references, allowing one to write code that uses references and can operate
in any monad that supports reference operations.
Create a new reference
Read the value of a reference
writeRef :: r a -> a -> m () Source
Write a new value to a reference
modifyRef :: r a -> (a -> a) -> m () Source
Mutate the contents of a reference
modifyRef' :: r a -> (a -> a) -> m () Source
Strict version of modifyRef
MonadRef TVar STM | |
MonadRef IORef IO | |
MonadRef r m => MonadRef r (MaybeT m) | |
MonadRef r m => MonadRef r (ListT m) | |
MonadRef r m => MonadRef r (IdentityT m) | |
(Monoid w, MonadRef r m) => MonadRef r (WriterT w m) | |
(Monoid w, MonadRef r m) => MonadRef r (WriterT w m) | |
MonadRef r m => MonadRef r (StateT s m) | |
MonadRef r m => MonadRef r (StateT s m) | |
MonadRef r m => MonadRef r (ReaderT r' m) | |
(Error e, MonadRef r m) => MonadRef r (ErrorT e m) | |
MonadRef r m => MonadRef r (ContT r' m) | |
MonadRef (STRef s) (ST s) |
class MonadRef r m => MonadAtomicRef r m | m -> r where Source
atomicModifyRef :: r a -> (a -> (a, b)) -> m b Source
Atomically mutate the contents of a reference
atomicModifyRef' :: r a -> (a -> (a, b)) -> m b Source
Strict version of atomicModifyRef. This forces both the value stored in the reference as well as the value returned.
MonadAtomicRef TVar STM | |
MonadAtomicRef IORef IO | |
MonadAtomicRef r m => MonadAtomicRef r (MaybeT m) | |
MonadAtomicRef r m => MonadAtomicRef r (ListT m) | |
MonadAtomicRef r m => MonadAtomicRef r (IdentityT m) | |
(Monoid w, MonadAtomicRef r m) => MonadAtomicRef r (WriterT w m) | |
(Monoid w, MonadAtomicRef r m) => MonadAtomicRef r (WriterT w m) | |
MonadAtomicRef r m => MonadAtomicRef r (StateT s m) | |
MonadAtomicRef r m => MonadAtomicRef r (StateT s m) | |
MonadAtomicRef r m => MonadAtomicRef r (ReaderT r' m) | |
(Error e, MonadAtomicRef r m) => MonadAtomicRef r (ErrorT e m) | |
MonadAtomicRef r m => MonadAtomicRef r (ContT r' m) |