Module

Uncurried.StateT

Package
purescript-uncurried-transformers
Repository
PureFunctor/purescript-uncurried-transformers

This module defines the state monad transformer, StateT.

#StateT Source

newtype StateT :: Type -> (Type -> Type) -> Type -> Typenewtype StateT s m a

The state monad transformer, implemented as a newtype over RWSET. Note that it's not recommended to stack newtypes of RWSET together as it incurs an indeterminate performance penalty that would otherwise be solved by just using RWSET.

Constructors

Instances

#stateT Source

stateT :: forall s m a. Functor m => (s -> m (a /\ s)) -> StateT s m a

Construct a StateT given a function that treads through some state.

#runStateT Source

runStateT :: forall s m a. MonadRec m => s -> StateT s m a -> m (a /\ s)

Runs a computation inside of StateT.

#evalStateT Source

evalStateT :: forall s m a. MonadRec m => s -> StateT s m a -> m a

Runs a computation inside of StateT, discarding the final state.

#execStateT Source

execStateT :: forall s m a. MonadRec m => s -> StateT s m a -> m s

Runs a computation inside of StateT, discarding the final result.

#hoistStateT Source

hoistStateT :: forall s m n a. (m ~> n) -> StateT s m a -> StateT s n a

Modifies the monadic context of a StateT.

#mapStateT Source

mapStateT :: forall s m1 m2 a1 a2. MonadRec m1 => Functor m2 => (m1 (a1 /\ s) -> m2 (a2 /\ s)) -> StateT s m1 a1 -> StateT s m2 a2

Modifies the result type of a StateT.

#withStateT Source

withStateT :: forall s m a. (s -> s) -> StateT s m a -> StateT s m a

Modifies the state of a StateT.