stateWriter-0.2.8: A faster variant of the RWS monad transformers.

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.RSS.Lazy

Contents

Description

Lazy RSS monad.

This is a variant of the classic "Control.Monad..RWS.Lazy" transformer, where the Writer part rides with the State part.

Synopsis

The RSS monad

type RSS r w s = RSST r w s Identity Source

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

rss :: Monoid w => (r -> s -> (a, s, w)) -> RSS r w s a Source

Construct an RSS computation from a function. (The inverse of runRSS.)

runRSS :: Monoid w => RSS r w s a -> r -> s -> (a, s, w) Source

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

evalRSS Source

Arguments

:: Monoid w 
=> RSS r w s a

RWS computation to execute

-> r

initial environment

-> s

initial value

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

execRSS Source

Arguments

:: Monoid w 
=> RSS r w s a

RWS computation to execute

-> r

initial environment

-> s

initial value

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

withRSS :: (r' -> s -> (r, s)) -> RSS r w s a -> RSS r' w s a Source

The RSST monad transformer

data RSST r w s m a Source

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.

Instances

(Monoid w, Monad m) => MonadRWS r w s (RSST r w s m) Source 
Monad m => MonadState s (RSST r w s m) Source 
Monad m => MonadReader r (RSST r w s m) Source 
(Monoid w, Monad m) => MonadWriter w (RSST r w s m) Source 
MonadTrans (RSST r w s) Source 
Monad m => Monad (RSST r w s m) Source 
Functor m => Functor (RSST r w s m) Source 
MonadFix m => MonadFix (RSST r w s m) Source 
(Functor m, Monad m) => Applicative (RSST r w s m) Source 
(Functor m, MonadPlus m) => Alternative (RSST r w s m) Source 
MonadPlus m => MonadPlus (RSST r w s m) Source 
MonadIO m => MonadIO (RSST r w s m) Source 

evalRSST Source

Arguments

:: (Monad m, Monoid w) 
=> RSST r w s m a

computation to execute

-> r

initial environment

-> s

initial value

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

execRSST Source

Arguments

:: (Monad m, Monoid w) 
=> RSST r w s m a

computation to execute

-> r

initial environment

-> s

initial value

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

withRSST :: (r' -> s -> (r, s)) -> RSST r w s m a -> RSST r' w s m a Source

withRSST f m executes action m with an initial environment and state modified by applying f.

Lazy Reader-writer-state monads