A monad containing an environment of type r, output of type w
and an updatable state of type s.
Moduletransformers-0.6.3.0Haskell2010
Control.Monad.Trans.RWS.Lazy
A monad transformer that combines ReaderT, WriterT and StateT. This version is lazy; for a constant-space version with almost the same interface, see Control.Monad.Trans.RWS.CPS.
Contents
Synopsis
- type RWS
- value rws
- value runRWS
- value evalRWS
- value execRWS
- value mapRWS
- value withRWS
- newtype RWST
- value evalRWST
- value execRWST
- value mapRWST
- value withRWST
- value reader
- value ask
- value local
- value asks
- value writer
- value tell
- value listen
- value listens
- value pass
- value censor
- value state
- value get
- value put
- value modify
- value gets
- value liftCallCC
- value liftCallCC'
- value liftCatch
- Packagetransformers-0.6.3.0
- Exports30
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceLazy.hs
The RWS monad
Construct an RWS computation from a function. (The inverse of runRWS.)
Unwrap an RWS computation as a function. (The inverse of rws.)
evalRWS :: RWS r w s aRWS computation to execute
-> rinitial environment
-> sinitial value
-> (a, w)final value and output
Evaluate a computation with the given initial state and environment, returning the final value and output, discarding the final state.
execRWS :: RWS r w s aRWS computation to execute
-> rinitial environment
-> sinitial value
-> (s, w)final state and output
Evaluate a computation with the given initial state and environment, returning the final state and output, discarding the final value.
The RWST monad transformer
A monad transformer adding reading an environment of type r,
collecting an output of type w and updating a state of type s
to an inner monad m.
Instances12MonadTrans, Monad, Functor, MonadFix, MonadFail, Applicative, …
Monoid w => MonadTrans (RWST r w s)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy(Monoid w, Monad m) => Monad (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.LazyFunctor m => Functor (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy(Monoid w, MonadFix m) => MonadFix (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy(Monoid w, MonadFail m) => MonadFail (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy(Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy(Monoid w, MonadPlus m) => MonadPlus (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy(Monoid w, MonadIO m) => MonadIO (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.LazyContravariant m => Contravariant (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.LazyGeneric (RWST r w s m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazytype Rep (RWST r w s m a) = D1 ('MetaDataDefined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy"RWST"
"Control.Monad.Trans.RWS.Lazy"
"transformers-0.6.3.0-0c8f"
'True) (C1 ('MetaCons"RWST"
'PrefixI 'True) (S1 ('MetaSel ('Just"runRWST"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (r -> s -> m (a, s, w)))))
evalRWST Evaluate a computation with the given initial state and environment, returning the final value and output, discarding the final state.
execRWST Evaluate a computation with the given initial state and environment, returning the final state and output, discarding the final value.
Reader operations
Constructor for computations in the reader monad (equivalent to asks).
Fetch the value of the environment.
Writer operations
Construct a writer computation from a (result, output) pair.
tell w is an action that produces the output w.
State operations
Construct a state monad computation from a state transformer function.
Fetch the current value of the state within the monad.
put s sets the state within the monad to s.
Lifting other operations
Uniform lifting of a callCC operation to the new monad.
This version rolls back to the original state on entering the
continuation.
In-situ lifting of a callCC operation to the new monad.
This version uses the current state on entering the continuation.
Lift a catchE operation to the new monad.
The uniformity property (see Control.Monad.Signatures) implies that
the lifted catchE discards any output or changes to the state from
the body on entering the handler.