Copyright | (C) 2015 KONISHI Yohsuke, (c) Andy Gill 2001, (c) Oregon Graduate Institute of Science and Technology, 2001 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | ocean0yohsuke@gmail.com |
Stability | experimental |
Portability | --- |
Safe Haskell | Safe |
Language | Haskell2010 |
This module extended RWS monad in mtl(monad-transformer-library).
- module Control.Monad.RWS
- class Monad m => MonadReader r m | m -> r where
- class (Monoid w, Monad m) => MonadWriter w m | m -> w where
- class Monad m => MonadState s m | m -> s where
Documentation
module Control.Monad.RWS
class Monad m => MonadReader r m | m -> r where
See examples in Control.Monad.Reader.
Note, the partially applied function type (->) r
is a simple reader monad.
See the instance
declaration below.
ask :: m r
Retrieves the monad environment.
:: (r -> r) | The function to modify the environment. |
-> m a |
|
-> m a |
Executes a computation in a modified environment.
:: (r -> a) | The selector function to apply to the environment. |
-> m a |
Retrieves a function of the current environment.
MonadReader r m => MonadReader r (MaybeT m) | |
MonadReader r m => MonadReader r (ListT m) | |
MonadReader r m => MonadReader r (IdentityT m) | |
MonadReader r ((->) r) | |
(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) | |
(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) | |
MonadReader r m => MonadReader r (StateT s m) | |
MonadReader r m => MonadReader r (StateT s m) | |
Monad m => MonadReader r (ReaderT r m) | |
MonadReader r m => MonadReader r (ExceptT e m) | |
(Error e, MonadReader r m) => MonadReader r (ErrorT e m) | |
MonadReader r' m => MonadReader r' (ContT r m) | |
(Monad m, Monoid w) => MonadReader r (RWST r w s m) | |
(Monad m, Monoid w) => MonadReader r (RWST r w s m) |
class (Monoid w, Monad m) => MonadWriter w m | m -> w where
writer :: (a, w) -> m a
embeds a simple writer action.writer
(a,w)
tell :: w -> m ()
is an action that produces the output tell
ww
.
listen :: m a -> m (a, w)
is an action that executes the action listen
mm
and adds
its output to the value of the computation.
pass :: m (a, w -> w) -> m a
is an action that executes the action pass
mm
, which
returns a value and a function, and returns the value, applying
the function to the output.
MonadWriter w m => MonadWriter w (MaybeT m) | |
MonadWriter w m => MonadWriter w (IdentityT m) | |
(Monoid w, Monad m) => MonadWriter w (WriterT w m) | |
(Monoid w, Monad m) => MonadWriter w (WriterT w m) | |
MonadWriter w m => MonadWriter w (StateT s m) | |
MonadWriter w m => MonadWriter w (StateT s m) | |
MonadWriter w m => MonadWriter w (ReaderT r m) | |
MonadWriter w m => MonadWriter w (ExceptT e m) | |
(Error e, MonadWriter w m) => MonadWriter w (ErrorT e m) | |
(Monoid w, Monad m) => MonadWriter w (RWST r w s m) | |
(Monoid w, Monad m) => MonadWriter w (RWST r w s m) |
class Monad m => MonadState s m | m -> s where
Minimal definition is either both of get
and put
or just state
get :: m s
Return the state from the internals of the monad.
put :: s -> m ()
Replace the state inside the monad.
state :: (s -> (a, s)) -> m a
Embed a simple state action into the monad.
MonadState s m => MonadState s (MaybeT m) | |
MonadState s m => MonadState s (ListT m) | |
MonadState s m => MonadState s (IdentityT m) | |
(Monoid w, MonadState s m) => MonadState s (WriterT w m) | |
(Monoid w, MonadState s m) => MonadState s (WriterT w m) | |
Monad m => MonadState s (StateT s m) | |
Monad m => MonadState s (StateT s m) | |
MonadState s m => MonadState s (ReaderT r m) | |
MonadState s m => MonadState s (ExceptT e m) | |
(Error e, MonadState s m) => MonadState s (ErrorT e m) | |
MonadState s m => MonadState s (ContT r m) | |
(Monad m, Monoid w) => MonadState s (RWST r w s m) | |
(Monad m, Monoid w) => MonadState s (RWST r w s m) |