HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulerebase-1.21.2Haskell2010

Rebase.Control.Monad.RWS.Class

  • 4 classes
  • 6 values
  • Packagerebase-1.21.2
  • Exports10
  • LanguageHaskell2010
  • LicenceMIT
  • SourceClass.hs
classclass Monad m => MonadReader r (m :: Type -> Type) | 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.

Methods

  • ask :: m r

    Retrieves the monad environment.

  • local :: (r -> r) -> m a -> m a

    Executes a computation in a modified environment.

  • reader :: (r -> a) -> m a

    Retrieves a function of the current environment.

Instances29MonadReader, …
valueasks
  1. :: MonadReader r m
  2. => (r -> a)

    The selector function to apply to the environment.

  3. -> m a
#

Retrieves a function of the current environment.

classclass Monad m => MonadState s (m :: Type -> Type) | m -> s where
#

Minimal definition is either both of get and put or just state

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.

Instances26MonadState, …
valuegets :: MonadState s m => (s -> a) -> m a
#

Gets specific component of the state, using a projection function supplied.

valuemodify :: 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.

valuemodify' :: MonadState s m => (s -> s) -> m ()
#

A variant of modify in which the computation is strict in the new state.

classclass (Monoid w, Monad m) => MonadWriter w (m :: Type -> Type) | m -> w where
#

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.

Instances25MonadWriter, …
valuecensor :: MonadWriter w m => (w -> w) -> m a -> m a
#

censor f m is an action that executes the action m and applies the function f to its output, leaving the return value unchanged.

valuelistens :: MonadWriter w m => (w -> b) -> m a -> m (a, b)
#

listens f m is an action that executes the action m and adds the result of applying f to the output to the value of the computation.

classclass (Monoid w, MonadReader r m, MonadWriter w m, MonadState s m) => MonadRWS r w s (m :: Type -> Type) | m -> r, m -> w, m -> s
#
Instances7MonadRWS, …