Module

Control.Monad.RWS.Trans

Package
transformers
Repository
purescript/purescript-transformers

This module defines the reader-writer-state monad transformer, RWST.

#RWSResult Source

data RWSResult state result writer

Constructors

#RWST Source

newtype RWST :: Type -> Type -> Type -> (Type -> Type) -> Type -> Typenewtype RWST r w s m a

The reader-writer-state monad transformer, which combines the operations of ReaderT, WriterT and StateT into a single monad transformer.

Constructors

Instances

#runRWST Source

runRWST :: forall r w s m a. RWST r w s m a -> r -> s -> m (RWSResult s a w)

Run a computation in the RWST monad.

#evalRWST Source

evalRWST :: forall r w s m a. Monad m => RWST r w s m a -> r -> s -> m (Tuple a w)

Run a computation in the RWST monad, discarding the final state.

#execRWST Source

execRWST :: forall r w s m a. Monad m => RWST r w s m a -> r -> s -> m (Tuple s w)

Run a computation in the RWST monad, discarding the result.

#mapRWST Source

mapRWST :: forall r w1 w2 s m1 m2 a1 a2. (m1 (RWSResult s a1 w1) -> m2 (RWSResult s a2 w2)) -> RWST r w1 s m1 a1 -> RWST r w2 s m2 a2

Change the result and accumulator types in a RWST monad action.

#withRWST Source

withRWST :: forall r1 r2 w s m a. (r2 -> s -> Tuple r1 s) -> RWST r1 w s m a -> RWST r2 w s m a

Change the context type in a RWST monad action.

Re-exports from Control.Monad.Trans.Class

#MonadTrans Source

class MonadTrans :: ((Type -> Type) -> Type -> Type) -> Constraintclass MonadTrans t  where

The MonadTrans type class represents monad transformers.

A monad transformer is a type constructor of kind (* -> *) -> * -> *, which takes a Monad as its first argument, and returns another Monad.

This allows us to add additional effects to an existing monad. By iterating this process, we create monad transformer stacks, which contain all of the effects required for a particular computation.

The laws state that lift is a Monad morphism.

Laws:

  • lift (pure a) = pure a
  • lift (do { x <- m ; y }) = do { x <- lift m ; lift y }

Members