Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class Monad m => MonadState tag s m | m tag -> s where
- modify :: MonadState tag s m => proxy tag -> (s -> s) -> m ()
- gets :: MonadState tag s m => proxy tag -> (s -> a) -> m a
- type State tag r = StateT tag r Identity
- runState :: proxy tag -> State tag s a -> s -> (a, s)
- evalState :: proxy tag -> State tag s a -> s -> a
- execState :: proxy tag -> State tag s a -> s -> s
- data StateT tag s m a
- stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
- runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s)
- evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a
- execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s
MonadState class
class Monad m => MonadState tag s m | m tag -> s where Source
See MonadState
.
get :: proxy tag -> m s Source
Return the state from the internals of the monad.
put :: proxy tag -> s -> m () Source
Replace the state inside the monad.
state :: proxy tag -> (s -> (a, s)) -> m a Source
Embed a simple state action into the monad.
(MonadTrans t, Monad (t m), MonadState tag s m) => MonadState tag s (t m) Source | |
MonadState tag s m => MonadState tag s (WrappedEther tag' m) Source | |
Monad m => MonadState tag s (StateT tag s m) Source | |
Monad m => MonadState tag s (StateT tag s m) Source |
modify :: MonadState tag s m => proxy tag -> (s -> s) -> m () Source
Modifies the state inside a state monad.
gets :: MonadState tag s m => proxy tag -> (s -> a) -> m a Source
Gets specific component of the state, using a projection function supplied.
The State monad
runState :: proxy tag -> State tag s a -> s -> (a, s) Source
Runs a State
with the given initial state
and returns both the final value and the final state.
evalState :: proxy tag -> State tag s a -> s -> a Source
Runs a State
with the given initial state
and returns the final value, discarding the final state.
execState :: proxy tag -> State tag s a -> s -> s Source
Runs a State
with the given initial state
and returns the final state, discarding the final value.
The StateT monad transformer
The state monad transformer.
The return
function leaves the state unchanged, while >>=
uses
the final state of the first computation as the initial state of the second.
stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a Source
Constructor for computations in the state monad transformer.
runStateT :: proxy tag -> StateT tag s m a -> s -> m (a, s) Source
Runs a StateT
with the given initial state
and returns both the final value and the final state.
evalStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m a Source
Runs a StateT
with the given initial state
and returns the final value, discarding the final state.
execStateT :: Monad m => proxy tag -> StateT tag s m a -> s -> m s Source
Runs a StateT
with the given initial state
and returns the final state, discarding the final value.