type State s = StateT s Identity { } #
newtype StateT s m a { } #
StateT { runStateT :: s -> m (a, s) }
The state monad transformer.
class Monad m => MonadState s m { } #

Methods

getS :: m s
putS :: s -> m ()
stateS :: (s -> (a, s)) -> m a
Class for monads with state.
runState :: (State s a) -> s -> (a, s) { } #
O(1). Run a State computation with an initial state.
evalState :: (State s a) -> s -> a { } #
O(1). Run a State computation, returning only the result.
execState :: (State s a) -> s -> s { } #
O(1). Run a State computation, returning only the final state.
mapState :: ((a, s) -> (b, s)) -> (State s a) -> State s b { } #
Map both the return value and state.
withState :: (s -> s) -> (State s a) -> State s a { } #
Transform the state.
<*> :: { } #
>>= :: { } #
evalStateT :: (Monad m) => (StateT s m a) -> s -> m a { } #
Run and return only the result.
execStateT :: (Monad m) => (StateT s m a) -> s -> m s { } #
Run and return only the final state.
mapStateT :: ((m (a, s)) -> n (b, s)) -> (StateT s m a) -> StateT s n b { } #
Map the inner computation.
withStateT :: (s -> s) -> (StateT s m a) -> StateT s m a { } #
Transform the state.
get :: (Monad m) => StateT s m s { } #
O(1). Retrieve the current state.
put :: (Monad m) => s -> StateT s m () { } #
O(1). Replace the state with a new value.
modify :: (Monad m) => (s -> s) -> StateT s m () { } #
O(1). Modify the state by applying a function.
modify' :: (Monad m) => (s -> s) -> StateT s m () { } #
O(1). Strictly modify the state.
gets :: (Monad m) => (s -> a) -> StateT s m a { } #
O(1). Retrieve a function of the current state.
state :: (Monad m) => (s -> (a, s)) -> StateT s m a { } #
O(1). Embed a state action into the monad.
instance Functor m => Functor (StateT s m) { }
instance MonadTrans (StateT s) { }
instance MonadIO m => MonadIO (StateT s m) { }
instance Monad m => MonadState s (StateT s m) { }