Modules 24
Control.Monad.RWS.Class
experimentalDeclaration of the MonadRWS class.
Inspired by the paper Functional Programming with Overloading and Higher-Order Polymorphism, Mark P Jones (http://web.cecs.pdx.edu/~mpj/) Advanced School of Functional Programming, 1995.
module Control.Monad.Reader.Class mtl-2.3.2 · 2 declarations
asks :: MonadReader r m => (r -> a) -> m a
Retrieves a function of the current environment.
(r -> a)The selector function to apply to the environment.
class Monad m => MonadReader r m
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.
local :: (r -> r) -> m a -> m a
Executes a computation in a modified environment.
Reader to run in the modified environment.
(r -> r)The function to modify the environment.
reader :: (r -> a) -> m a
Retrieves a function of the current environment.
(r -> a)The selector function to apply to the environment.
module Control.Monad.State.Class mtl-2.3.2 · 4 declarations
gets :: MonadState s m => (s -> a) -> m a
Gets specific component of the state, using a projection function supplied.
modify :: MonadState s m => (s -> s) -> m ()
Monadic state transformer.
Maps an old state to a new state inside a state monad. The old state is thrown away.
Main> :t modify ((+1) :: Int -> Int)
modify (...) :: (MonadState Int a) => a ()This says that modify (+1) acts over any
Monad that is a member of the MonadState class,
with an Int state.
modify' :: MonadState s m => (s -> s) -> m ()
A variant of modify in which the computation is strict in the
new state.
class Monad m => MonadState s m
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.
module Control.Monad.Writer.Class mtl-2.3.2 · 3 declarations
censor :: MonadWriter w m => (w -> w) -> m a -> m a
is an action that executes the action censor f mm and
applies the function f to its output, leaving the return value
unchanged.
censorf m =pass(liftM(\x -> (x,f)) m)
listens :: MonadWriter w m => (w -> b) -> m a -> m (a, b)
is an action that executes the action listens f mm and adds
the result of applying f to the output to the value of the computation.
listensf m =liftM(id *** f) (listenm)
class (Monoid w, Monad m) => MonadWriter w m
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.
Instances
7
instance (Monoid w, Monad m) => MonadRWS r w s (CPS.RWST r w s m)instance (Monoid w, Monad m) => MonadRWS r w s (Lazy.RWST r w s m)instance (Monoid w, Monad m) => MonadRWS r w s (Strict.RWST r w s m)instance MonadRWS r w s m => MonadRWS r w s (ExceptT e m)instance MonadRWS r w s m => MonadRWS r w s (IdentityT m)instance MonadRWS r w s m => MonadRWS r w s (MaybeT m)instance (MonadRWS r w s m, MonadRWS r w s n) => MonadRWS r w s (Product m n)
- Maintainer
- libraries@haskell.org
- Portability
- non-portable (multi-param classes, functional dependencies)
- Copyright
- (c) Andy Gill 2001, (c) Oregon Graduate Institute of Science and Technology, 2001
- License
- BSD-style (see the file LICENSE)
Build record and source files
Community contribution. The service has not verified this documentation. The generator reported 6 diagnostics.
Target: Linux on x86-64. Some inferred types and resolved links are not available.
Generator: aihc-haddock-858b1951-web-1
Metadata snapshot: 032b29dc8ecd03eaae7b1a84a40ef8560125381762749b2f47333bc9a4f4bb8e
Open the dependency plan · Download the documentation model
- aihc-base-4.21.2.0 · Core library · Cabal file
- aihc-prim-0.13.0 · Core library · Cabal file
- aihc-rts-1.0.2 · Core library · Cabal file
- mtl-2.3.2 · Cabal revision 1 · Cabal file · Source archive
- transformers-0.6.3.0 · Cabal revision 2 · Cabal file · Source archive