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 m where
- class MonadRef m => MonadAtomicRef m where
- atomicModifyRef :: Ref m a -> (a -> (a, b)) -> m b
- atomicModifyRef' :: Ref m a -> (a -> (a, b)) -> m b
Documentation
class Monad m => MonadRef m 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.
newRef :: a -> m (Ref m a) Source
Create a new reference
readRef :: Ref m a -> m a Source
Read the value of a reference
writeRef :: Ref m a -> a -> m () Source
Write a new value to a reference
modifyRef :: Ref m a -> (a -> a) -> m () Source
Mutate the contents of a reference
modifyRef' :: Ref m a -> (a -> a) -> m () Source
Strict version of modifyRef
MonadRef IO | |
MonadRef STM | |
MonadRef (ST s) | |
MonadRef m => MonadRef (MaybeT m) | |
MonadRef m => MonadRef (ListT m) | |
MonadRef m => MonadRef (IdentityT m) | |
(Monoid w, MonadRef m) => MonadRef (WriterT w m) | |
(Monoid w, MonadRef m) => MonadRef (WriterT w m) | |
MonadRef m => MonadRef (StateT s m) | |
MonadRef m => MonadRef (StateT s m) | |
MonadRef m => MonadRef (ReaderT r m) | |
(Error e, MonadRef m) => MonadRef (ErrorT e m) | |
MonadRef m => MonadRef (ContT r m) |
class MonadRef m => MonadAtomicRef m where Source
atomicModifyRef :: Ref m a -> (a -> (a, b)) -> m b Source
Atomically mutate the contents of a reference
atomicModifyRef' :: Ref m 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 IO | |
MonadAtomicRef STM | |
MonadAtomicRef m => MonadAtomicRef (MaybeT m) | |
MonadAtomicRef m => MonadAtomicRef (ListT m) | |
MonadAtomicRef m => MonadAtomicRef (IdentityT m) | |
(Monoid w, MonadAtomicRef m) => MonadAtomicRef (WriterT w m) | |
(Monoid w, MonadAtomicRef m) => MonadAtomicRef (WriterT w m) | |
MonadAtomicRef m => MonadAtomicRef (StateT s m) | |
MonadAtomicRef m => MonadAtomicRef (StateT s m) | |
MonadAtomicRef m => MonadAtomicRef (ReaderT r m) | |
(Error e, MonadAtomicRef m) => MonadAtomicRef (ErrorT e m) | |
MonadAtomicRef m => MonadAtomicRef (ContT r m) |