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 | Safe |
Language | Haskell98 |
Synopsis
- 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
Instances
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.