ref-fd-0.5: A type class for monads with references using functional dependencies.
Copyright(c) Harvard University 2006-2011
(c) Geoffrey Mainland 2011-2014
LicenseBSD-style
MaintainerGeoffrey Mainland <mainland@cs.drexel.edu>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Ref

Description

 
Synopsis

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.

Minimal complete definition

newRef, readRef, writeRef

Methods

newRef :: a -> m (r a) Source #

Create a new reference

readRef :: r a -> m a Source #

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

Instances

Instances details
MonadRef TVar STM Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> STM (TVar a) Source #

readRef :: TVar a -> STM a Source #

writeRef :: TVar a -> a -> STM () Source #

modifyRef :: TVar a -> (a -> a) -> STM () Source #

modifyRef' :: TVar a -> (a -> a) -> STM () Source #

MonadRef IORef IO Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> IO (IORef a) Source #

readRef :: IORef a -> IO a Source #

writeRef :: IORef a -> a -> IO () Source #

modifyRef :: IORef a -> (a -> a) -> IO () Source #

modifyRef' :: IORef a -> (a -> a) -> IO () Source #

MonadRef r m => MonadRef r (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> MaybeT m (r a) Source #

readRef :: r a -> MaybeT m a Source #

writeRef :: r a -> a -> MaybeT m () Source #

modifyRef :: r a -> (a -> a) -> MaybeT m () Source #

modifyRef' :: r a -> (a -> a) -> MaybeT m () Source #

MonadRef r m => MonadRef r (ListT m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> ListT m (r a) Source #

readRef :: r a -> ListT m a Source #

writeRef :: r a -> a -> ListT m () Source #

modifyRef :: r a -> (a -> a) -> ListT m () Source #

modifyRef' :: r a -> (a -> a) -> ListT m () Source #

(Monoid w, MonadRef r m) => MonadRef r (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> WriterT w m (r a) Source #

readRef :: r a -> WriterT w m a Source #

writeRef :: r a -> a -> WriterT w m () Source #

modifyRef :: r a -> (a -> a) -> WriterT w m () Source #

modifyRef' :: r a -> (a -> a) -> WriterT w m () Source #

(Monoid w, MonadRef r m) => MonadRef r (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> WriterT w m (r a) Source #

readRef :: r a -> WriterT w m a Source #

writeRef :: r a -> a -> WriterT w m () Source #

modifyRef :: r a -> (a -> a) -> WriterT w m () Source #

modifyRef' :: r a -> (a -> a) -> WriterT w m () Source #

MonadRef r m => MonadRef r (StateT s m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> StateT s m (r a) Source #

readRef :: r a -> StateT s m a Source #

writeRef :: r a -> a -> StateT s m () Source #

modifyRef :: r a -> (a -> a) -> StateT s m () Source #

modifyRef' :: r a -> (a -> a) -> StateT s m () Source #

MonadRef r m => MonadRef r (StateT s m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> StateT s m (r a) Source #

readRef :: r a -> StateT s m a Source #

writeRef :: r a -> a -> StateT s m () Source #

modifyRef :: r a -> (a -> a) -> StateT s m () Source #

modifyRef' :: r a -> (a -> a) -> StateT s m () Source #

MonadRef r m => MonadRef r (ReaderT r' m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> ReaderT r' m (r a) Source #

readRef :: r a -> ReaderT r' m a Source #

writeRef :: r a -> a -> ReaderT r' m () Source #

modifyRef :: r a -> (a -> a) -> ReaderT r' m () Source #

modifyRef' :: r a -> (a -> a) -> ReaderT r' m () Source #

MonadRef r m => MonadRef r (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> IdentityT m (r a) Source #

readRef :: r a -> IdentityT m a Source #

writeRef :: r a -> a -> IdentityT m () Source #

modifyRef :: r a -> (a -> a) -> IdentityT m () Source #

modifyRef' :: r a -> (a -> a) -> IdentityT m () Source #

MonadRef r m => MonadRef r (ExceptT e m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> ExceptT e m (r a) Source #

readRef :: r a -> ExceptT e m a Source #

writeRef :: r a -> a -> ExceptT e m () Source #

modifyRef :: r a -> (a -> a) -> ExceptT e m () Source #

modifyRef' :: r a -> (a -> a) -> ExceptT e m () Source #

(Error e, MonadRef r m) => MonadRef r (ErrorT e m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> ErrorT e m (r a) Source #

readRef :: r a -> ErrorT e m a Source #

writeRef :: r a -> a -> ErrorT e m () Source #

modifyRef :: r a -> (a -> a) -> ErrorT e m () Source #

modifyRef' :: r a -> (a -> a) -> ErrorT e m () Source #

MonadRef r m => MonadRef r (ContT r' m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> ContT r' m (r a) Source #

readRef :: r a -> ContT r' m a Source #

writeRef :: r a -> a -> ContT r' m () Source #

modifyRef :: r a -> (a -> a) -> ContT r' m () Source #

modifyRef' :: r a -> (a -> a) -> ContT r' m () Source #

MonadRef (STRef s) (ST s) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

newRef :: a -> ST s (STRef s a) Source #

readRef :: STRef s a -> ST s a Source #

writeRef :: STRef s a -> a -> ST s () Source #

modifyRef :: STRef s a -> (a -> a) -> ST s () Source #

modifyRef' :: STRef s a -> (a -> a) -> ST s () Source #

class MonadRef r m => MonadAtomicRef r m | m -> r where Source #

Minimal complete definition

atomicModifyRef

Methods

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.

Instances

Instances details
MonadAtomicRef TVar STM Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: TVar a -> (a -> (a, b)) -> STM b Source #

atomicModifyRef' :: TVar a -> (a -> (a, b)) -> STM b Source #

MonadAtomicRef IORef IO Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: IORef a -> (a -> (a, b)) -> IO b Source #

atomicModifyRef' :: IORef a -> (a -> (a, b)) -> IO b Source #

MonadAtomicRef r m => MonadAtomicRef r (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> MaybeT m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> MaybeT m b Source #

MonadAtomicRef r m => MonadAtomicRef r (ListT m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> ListT m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> ListT m b Source #

(Monoid w, MonadAtomicRef r m) => MonadAtomicRef r (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> WriterT w m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> WriterT w m b Source #

(Monoid w, MonadAtomicRef r m) => MonadAtomicRef r (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> WriterT w m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> WriterT w m b Source #

MonadAtomicRef r m => MonadAtomicRef r (StateT s m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> StateT s m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> StateT s m b Source #

MonadAtomicRef r m => MonadAtomicRef r (StateT s m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> StateT s m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> StateT s m b Source #

MonadAtomicRef r m => MonadAtomicRef r (ReaderT r' m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> ReaderT r' m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> ReaderT r' m b Source #

MonadAtomicRef r m => MonadAtomicRef r (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> IdentityT m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> IdentityT m b Source #

(Error e, MonadAtomicRef r m) => MonadAtomicRef r (ErrorT e m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> ErrorT e m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> ErrorT e m b Source #

MonadAtomicRef r m => MonadAtomicRef r (ContT r' m) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> ContT r' m b Source #

atomicModifyRef' :: r a -> (a -> (a, b)) -> ContT r' m b Source #

MonadAtomicRef (STRef s) (ST s) Source # 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: STRef s a -> (a -> (a, b)) -> ST s b Source #

atomicModifyRef' :: STRef s a -> (a -> (a, b)) -> ST s b Source #