stateWriter-0.4.0: A faster variant of the RWS monad transformers.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Trans.RSS.Strict

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

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

Instances details
(Monoid w, Monad m) => MonadRWS r w s (RSST r w s m) Source # 
Instance details

Defined in Control.Monad.Trans.RSS.Strict

(Monoid w, MonadError e m) => MonadError e (RSST r w s m) Source # 
Instance details

Defined in Control.Monad.Trans.RSS.Strict

Methods

throwError :: e -> RSST r w s m a #

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

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

Defined in Control.Monad.Trans.RSS.Strict

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 # 
Instance details

Defined in Control.Monad.Trans.RSS.Strict

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 # 
Instance details

Defined in Control.Monad.Trans.RSS.Strict

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 # 
Instance details

Defined in Control.Monad.Trans.RSS.Strict

Methods

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

MonadFail m => MonadFail (RSST r w s m) Source # 
Instance details

Defined in Control.Monad.Trans.RSS.Strict

Methods

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

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

Defined in Control.Monad.Trans.RSS.Strict

Methods

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

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

Defined in Control.Monad.Trans.RSS.Strict

Methods

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

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

Defined in Control.Monad.Trans.RSS.Strict

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] #

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

Defined in Control.Monad.Trans.RSS.Strict

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 #

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

(*>) :: 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 #

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

Defined in Control.Monad.Trans.RSS.Strict

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 #

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

Defined in Control.Monad.Trans.RSS.Strict

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 #

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

Defined in Control.Monad.Trans.RSS.Strict

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

:: (Monoid w, Monad m) 
=> 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

:: (Monoid w, Monad m) 
=> 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.

Helpers

liftCatch :: Catch e m (a, (s, w)) -> Catch e (RSST r w s m) a Source #

Lift a catchE operation to the new monad.