Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Effect.State
Contents
- class MemberEffect State (State s) l => EffectState s l
- data State s a
- runState :: s -> Effect (State s :+ l) a -> Effect l (a, s)
- evalState :: s -> Effect (State s :+ l) a -> Effect l a
- execState :: s -> Effect (State s :+ l) a -> Effect l s
- get :: EffectState s l => Effect l s
- gets :: EffectState s l => (s -> a) -> Effect l a
- put :: EffectState s l => s -> Effect l ()
- modify :: EffectState s l => (s -> s) -> Effect l ()
- modify' :: EffectState s l => (s -> s) -> Effect l ()
- state :: EffectState s l => (s -> (a, s)) -> Effect l a
- withState :: EffectState s l => (s -> s) -> Effect l a -> Effect l a
Documentation
class MemberEffect State (State s) l => EffectState s l Source #
Instances
MemberEffect (* -> * -> *) State (State s) l => EffectState s l Source # | |
An effect where a state value is threaded throughout the computation.
runState :: s -> Effect (State s :+ l) a -> Effect l (a, s) Source #
Completely handles a State
effect by providing an
initial state, and making the final state explicit.
evalState :: s -> Effect (State s :+ l) a -> Effect l a Source #
Completely handles a State
effect, and discards the final state.
execState :: s -> Effect (State s :+ l) a -> Effect l s Source #
Completely handles a State
effect, and discards the final value.
get :: EffectState s l => Effect l s Source #
Gets the current state.
gets :: EffectState s l => (s -> a) -> Effect l a Source #
Gets a value that is a function of the current state.
put :: EffectState s l => s -> Effect l () Source #
Replaces the current state.
modify :: EffectState s l => (s -> s) -> Effect l () Source #
Applies a pure modifier to the state value.
modify' :: EffectState s l => (s -> s) -> Effect l () Source #
Applies a pure modifier to the state value. The modified value is converted to weak head normal form.
state :: EffectState s l => (s -> (a, s)) -> Effect l a Source #
Lifts a stateful computation to the Effect
monad.
withState :: EffectState s l => (s -> s) -> Effect l a -> Effect l a Source #
Runs a computation with a modified state value.
withState f x = modify f >> x