HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulererebase-1.21.2Haskell2010

Control.Monad.Trans.RWS.Strict

  • 2 types
  • 28 values
  • Packagererebase-1.21.2
  • Exports30
  • LanguageHaskell2010
  • LicenceMIT
  • SourceStrict.hs
typetype RWS r w s = RWST r w s Identity
#

A monad containing an environment of type r, output of type w and an updatable state of type s.

valueliftCallCC
  1. :: Monoid w
  2. => CallCC m (a, s, w) (b, s, w)
  3. -> CallCC (RWST r w s m) a b
#

Uniform lifting of a callCC operation to the new monad. This version rolls back to the original state on entering the continuation.

valuegets :: (Monoid w, Monad m) => (s -> a) -> RWST r w s m a
#

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

valuereader :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a
#

Constructor for computations in the reader monad (equivalent to asks).

valueget :: (Monoid w, Monad m) => RWST r w s m s
#

Fetch the current value of the state within the monad.

valuestate :: (Monoid w, Monad m) => (s -> (a, s)) -> RWST r w s m a
#

Construct a state monad computation from a state transformer function.

valuepass :: Monad m => RWST r w s m (a, w -> w) -> RWST r w s 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.

valuetell :: Monad m => w -> RWST r w s m ()
#

tell w is an action that produces the output w.

valuewriter :: Monad m => (a, w) -> RWST r w s m a
#

Construct a writer computation from a (result, output) pair.

newtypenewtype RWST r w s (m :: Type -> Type) a
#

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.

Constructors

Instances40MonadRWS, MonadAccum, MonadError, MonadReader, MonadState, MonadWriter, …
valueliftCallCC'
  1. :: Monoid w
  2. => CallCC m (a, s, w) (b, s, w)
  3. -> CallCC (RWST r w s m) a b
#

In-situ lifting of a callCC operation to the new monad. This version uses the current state on entering the continuation.

valueevalRWS
  1. :: RWS r w s a

    RWS computation to execute

  2. -> r

    initial environment

  3. -> s

    initial value

  4. -> (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.

valueevalRWST
  1. :: Monad m
  2. => RWST r w s m a

    computation to execute

  3. -> r

    initial environment

  4. -> s

    initial value

  5. -> m (a, w)

    computation yielding final value and output

#

Evaluate a computation with the given initial state and environment, returning the final value and output, discarding the final state.

valueexecRWS
  1. :: RWS r w s a

    RWS computation to execute

  2. -> r

    initial environment

  3. -> s

    initial value

  4. -> (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.

valueexecRWST
  1. :: Monad m
  2. => RWST r w s m a

    computation to execute

  3. -> r

    initial environment

  4. -> s

    initial value

  5. -> m (s, w)

    computation yielding final state and output

#

Evaluate a computation with the given initial state and environment, returning the final state and output, discarding the final value.

valuemapRWS :: ((a, s, w) -> (b, s, w')) -> RWS r w s a -> RWS r w' s b
#

Map the return value, final state and output of a computation using the given function.

valuerunRWS :: RWS r w s a -> r -> s -> (a, s, w)
#

Unwrap an RWS computation as a function. (The inverse of rws.)

valuerws :: (r -> s -> (a, s, w)) -> RWS r w s a
#

Construct an RWS computation from a function. (The inverse of runRWS.)