deepcontrol-0.1.0.0: Enable deeper level style of programming than the usual control provides

Safe HaskellSafe
LanguageHaskell2010

DeepControl.Monad.RWS

Synopsis

Documentation

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.

Minimal complete definition

(ask | reader), local

Methods

ask :: m r

Retrieves the monad environment.

local

Arguments

:: (r -> r)

The function to modify the environment.

-> m a

Reader to run in the modified environment.

-> m a 

Executes a computation in a modified environment.

reader

Arguments

:: (r -> a)

The selector function to apply to the environment.

-> m a 

Retrieves a function of the current environment.

Instances

MonadReader r m => MonadReader r (MaybeT m) 
MonadReader r m => MonadReader r (ListT m) 
MonadReader r m => MonadReader r (IdentityT m) 
MonadReader r ((->) r) 
MonadReader r (Reader 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) 
Monoid w => MonadReader r (RWS r w s) 
(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

Minimal complete definition

(writer | tell), listen, pass

Methods

writer :: (a, w) -> m a

writer (a,w) embeds a simple writer action.

tell :: w -> m ()

tell w is an action that produces the output w.

listen :: m a -> m (a, w)

listen m is an action that executes the action m and adds its output to the value of the computation.

pass :: m (a, w -> w) -> m a

pass m is an action that executes the action m, which returns a value and a function, and returns the value, applying the function to the output.

Instances

MonadWriter w m => MonadWriter w (MaybeT m) 
MonadWriter w m => MonadWriter w (IdentityT m) 
Monoid w => MonadWriter w (Writer w) 
(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 => MonadWriter w (RWS r w s) 
(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

Minimal complete definition

state | get, put

Methods

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.

Instances

MonadState s m => MonadState s (MaybeT m) 
MonadState s m => MonadState s (ListT m) 
MonadState s m => MonadState s (IdentityT m) 
MonadState s (State s) 
(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) 
Monoid w => MonadState s (RWS r w s) 
(Monad m, Monoid w) => MonadState s (RWST r w s m) 
(Monad m, Monoid w) => MonadState s (RWST r w s m) 

newtype RWS r w s a Source

Constructors

RWS 

Fields

runRWS :: r -> s -> (a, s, w)
 

Instances

Monoid w => MonadReader r (RWS r w s) Source 
Monoid w => MonadState s (RWS r w s) Source 
Monoid w => MonadWriter w (RWS r w s) Source 
Monoid w => Monad (RWS r w s) Source 
Functor (RWS r w s) Source 
Monoid w => Applicative (RWS r w s) Source 

rws :: (r -> s -> (a, s, w)) -> RWS r w s a Source

evalRWS :: RWS r w s a -> r -> s -> (a, w) Source

execRWS :: RWS r w s a -> r -> s -> (s, w) Source