| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Mikan.Utils.StrictState
Description
This is a plain strict state monad, where state update, monadic binding and return are all strict. If you only need a single strict state effect, use this module.
Do not use Control.Monad.State.Strict for the same purpose; it's not even strict in state updates and is much less amenable to GHC optimizations than this module.
Synopsis
- newtype StateT s (m :: Type -> Type) a = StateT {
- runStateT# :: s -> m (Pair a s)
- execStateT :: Monad m => StateT s m a -> s -> m s
- runStateT :: Monad m => StateT s m a -> s -> m (a, s)
- evalStateT :: Monad m => StateT s m a -> s -> m a
- newtype State s a = State {
- runState# :: s -> (# a, s #)
- execState :: State s a -> s -> s
- runState :: State s a -> s -> (a, s)
- evalState :: State s a -> s -> a
- gets :: MonadState s m => (s -> a) -> m a
- modify :: MonadState s m => (s -> s) -> m ()
- class Monad m => MonadState s (m :: Type -> Type) | m -> s where
Strict state monad transformers
newtype StateT s (m :: Type -> Type) a Source #
Constructors
| StateT | |
Fields
| |
Instances
execStateT :: Monad m => StateT s m a -> s -> m s Source #
evalStateT :: Monad m => StateT s m a -> s -> m a Source #
Strict state monad
Instances
| MonadState s (State s) Source # | |
| Applicative (State s) Source # | |
| Functor (State s) Source # | |
| Monad (State s) Source # | |
| ExpandCase ('TupleRep '[LiftedRep, LiftedRep]) (State s a) Source # | |
| type Result ('TupleRep '[LiftedRep, LiftedRep]) (State s a) Source # | |
Strict state operations
gets :: MonadState s m => (s -> a) -> m a Source #
modify :: MonadState s m => (s -> s) -> m () Source #
Re-exports
class Monad m => MonadState s (m :: Type -> Type) | m -> s where #
Minimal definition is either both of get and put or just state
Methods
Return the state from the internals of the monad.
Replace the state inside the monad.
state :: (s -> (a, s)) -> m a #
Embed a simple state action into the monad.