ref-tf-0.4.0.2: A type class for monads with references using type families.

Copyright(c) Harvard University 2006-2011
(c) Geoffrey Mainland 2011-2014
LicenseBSD-style
MaintainerGeoffrey Mainland <mainland@cs.drexel.edu>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell98

Control.Monad.Ref

Description

 
Synopsis

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.

Minimal complete definition

newRef, readRef, writeRef

Associated Types

type Ref m :: * -> * Source #

Methods

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
MonadRef IO Source # 
Instance details

Defined in Control.Monad.Ref

Associated Types

type Ref IO :: Type -> Type Source #

Methods

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

readRef :: Ref IO a -> IO a Source #

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

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

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

MonadRef STM Source # 
Instance details

Defined in Control.Monad.Ref

Associated Types

type Ref STM :: Type -> Type Source #

Methods

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

readRef :: Ref STM a -> STM a Source #

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

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

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

MonadRef (ST s) Source # 
Instance details

Defined in Control.Monad.Ref

Associated Types

type Ref (ST s) :: Type -> Type Source #

Methods

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

readRef :: Ref (ST s) a -> ST s a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (MaybeT m) :: Type -> Type Source #

Methods

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

readRef :: Ref (MaybeT m) a -> MaybeT m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (ListT m) :: Type -> Type Source #

Methods

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

readRef :: Ref (ListT m) a -> ListT m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (WriterT w m) :: Type -> Type Source #

Methods

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

readRef :: Ref (WriterT w m) a -> WriterT w m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (WriterT w m) :: Type -> Type Source #

Methods

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

readRef :: Ref (WriterT w m) a -> WriterT w m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (StateT s m) :: Type -> Type Source #

Methods

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

readRef :: Ref (StateT s m) a -> StateT s m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (StateT s m) :: Type -> Type Source #

Methods

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

readRef :: Ref (StateT s m) a -> StateT s m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (IdentityT m) :: Type -> Type Source #

Methods

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

readRef :: Ref (IdentityT m) a -> IdentityT m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (ExceptT e m) :: Type -> Type Source #

Methods

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

readRef :: Ref (ExceptT e m) a -> ExceptT e m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (ErrorT e m) :: Type -> Type Source #

Methods

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

readRef :: Ref (ErrorT e m) a -> ErrorT e m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (ReaderT r m) :: Type -> Type Source #

Methods

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

readRef :: Ref (ReaderT r m) a -> ReaderT r m a Source #

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

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

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

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

Defined in Control.Monad.Ref

Associated Types

type Ref (ContT r m) :: Type -> Type Source #

Methods

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

readRef :: Ref (ContT r m) a -> ContT r m a Source #

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

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

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

class MonadRef m => MonadAtomicRef m where Source #

Minimal complete definition

atomicModifyRef

Methods

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.

Instances
MonadAtomicRef IO Source # 
Instance details

Defined in Control.Monad.Ref

Methods

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

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

MonadAtomicRef STM Source # 
Instance details

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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

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

Defined in Control.Monad.Ref

Methods

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

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