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

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Trans.RSS.Lazy

Contents

Synopsis

The RWS 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 => MonadReader r (RSST r w s m) Source # 

Methods

ask :: RSST r w s m r #

local :: (r -> r) -> RSST r w s m a -> RSST r w s m a #

reader :: (r -> a) -> RSST r w s m a #

Monad m => MonadState s (RSST r w s m) Source # 

Methods

get :: RSST r w s m s #

put :: s -> RSST r w s m () #

state :: (s -> (a, s)) -> RSST r w s m a #

(Monoid w, Monad m) => MonadWriter w (RSST r w s m) Source # 

Methods

writer :: (a, w) -> RSST r w s m a #

tell :: w -> RSST r w s m () #

listen :: RSST r w s m a -> RSST r w s m (a, w) #

pass :: RSST r w s m (a, w -> w) -> RSST r w s m a #

MonadTrans (RSST r w s) Source # 

Methods

lift :: Monad m => m a -> RSST r w s m a #

Monad m => Monad (RSST r w s m) Source # 

Methods

(>>=) :: RSST r w s m a -> (a -> RSST r w s m b) -> RSST r w s m b #

(>>) :: RSST r w s m a -> RSST r w s m b -> RSST r w s m b #

return :: a -> RSST r w s m a #

fail :: String -> RSST r w s m a #

Functor m => Functor (RSST r w s m) Source # 

Methods

fmap :: (a -> b) -> RSST r w s m a -> RSST r w s m b #

(<$) :: a -> RSST r w s m b -> RSST r w s m a #

MonadFix m => MonadFix (RSST r w s m) Source # 

Methods

mfix :: (a -> RSST r w s m a) -> RSST r w s m a #

(Functor m, Monad m) => Applicative (RSST r w s m) Source # 

Methods

pure :: a -> RSST r w s m a #

(<*>) :: RSST r w s m (a -> b) -> RSST r w s m a -> RSST r w s m b #

(*>) :: RSST r w s m a -> RSST r w s m b -> RSST r w s m b #

(<*) :: RSST r w s m a -> RSST r w s m b -> RSST r w s m a #

MonadIO m => MonadIO (RSST r w s m) Source # 

Methods

liftIO :: IO a -> RSST r w s m a #

(Functor m, MonadPlus m) => Alternative (RSST r w s m) Source # 

Methods

empty :: RSST r w s m a #

(<|>) :: RSST r w s m a -> RSST r w s m a -> RSST r w s m a #

some :: RSST r w s m a -> RSST r w s m [a] #

many :: RSST r w s m a -> RSST r w s m [a] #

MonadPlus m => MonadPlus (RSST r w s m) Source # 

Methods

mzero :: RSST r w s m a #

mplus :: RSST r w s m a -> RSST r w s m a -> RSST r w s m a #

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