Module

Control.Monad.RWS.Trans

Package
purescript-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 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 a m s w r. RWST r w s m a -> r -> s -> m (RWSResult s a w)

Run a computation in the RWST monad.

#evalRWST Source

evalRWST :: forall a m s w r. 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 a m s w r. 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 a2 a1 m2 m1 s w2 w1 r. (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 a m s w r2 r1. (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 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