Copyright | (c) Ivan Lazar Miljenovic |
---|---|
License | 3-Clause BSD-style |
Maintainer | Ivan.Miljenovic@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Strict stateful computations.
- state :: forall m s a. HasState s m => (s -> (a, s)) -> m a
- get :: HasState s m => m s
- gets :: HasState s m => (s -> a) -> m a
- put :: HasState s m => s -> m ()
- modify :: HasState s m => (s -> s) -> m ()
- modify' :: HasState s m => (s -> s) -> m ()
- newtype StateT s m a :: * -> (* -> *) -> * -> * = StateT {
- runStateT :: s -> m (a, s)
- type HasState s m = SatisfyConstraint (IsState s) m
- class MonadTower m => IsState s m
Documentation
state :: forall m s a. HasState s m => (s -> (a, s)) -> m a Source
Embed a simple state action into the monad stack.
gets :: HasState s m => (s -> a) -> m a Source
Apply a function to the stateful environment. Equivalent to
fmap f
.get
modify' :: HasState s m => (s -> s) -> m () Source
A variant of modify
in which the computation is strict in the
new state.
newtype StateT s m a :: * -> (* -> *) -> * -> *
A state transformer monad parameterized by:
s
- The state.m
- The inner monad.
The return
function leaves the state unchanged, while >>=
uses
the final state of the first computation as the initial state of
the second.
MonadTower m => IsState s (StateT s m) | |
MonadTrans (StateT s) | |
MonadLevel m => ConstraintPassThrough (IsTransformer (StateT s)) (ListT m) True | |
MonadLevel m => ConstraintPassThrough (IsTransformer (StateT s)) (ContT r m) True | |
(Functor m, MonadPlus m) => Alternative (StateT s m) | |
Monad m => Monad (StateT s m) | |
Functor m => Functor (StateT s m) | |
MonadFix m => MonadFix (StateT s m) | |
MonadPlus m => MonadPlus (StateT s m) | |
(Functor m, Monad m) => Applicative (StateT s m) | |
MonadIO m => MonadIO (StateT s m) | |
MonadTower m => MonadLevel_ (StateT s m) | |
MonadTower m => MonadTower_ (StateT s m) | |
type LowerMonad (StateT s m) = m | |
type WithLower_ (StateT s m) = AddIG | |
type AllowOtherValues (StateT s m) = True | |
type DefaultAllowConstraints (StateT s m) = True | |
type BaseMonad (StateT s m) = BaseMonad m | |
type InnerValue (StateT s m) a = (a, s) |
type HasState s m = SatisfyConstraint (IsState s) m Source
A monad stack containing a stateful environment of type s
.
class MonadTower m => IsState s m Source
The minimal definition needed for a monad providing a stateful environment.
MonadTower m => IsState s (StateT s m) | |
MonadTower m => IsState s (StateT s m) | |
(MonadTower m, Monoid w) => IsState s (RWST r w s m) | |
(MonadTower m, Monoid w) => IsState s (RWST r w s m) | |
ValidConstraint (IsState s) | |
MonadTower m => ConstraintPassThrough (IsState s) (ListT m) True | |
MonadTower m => ConstraintPassThrough (IsState s) (ContT r m) True | |
type ConstraintSatisfied (IsState s) m |