DA.Action.State
Data Types
data State s a
A value of type `State s a` represents a computation that has access to a state variable
of type `s` and produces a value of type `a`.
>>> runState (modify (+1)) 0
((), 1)
>>> evalState (modify (+1)) 0
()
>>> execState (modify (+1)) 0
1
>>> runState (do x <- get; modify (+1); pure x) 0
(0, 1)
>>> runState (put 1) 0
((), 1)
>>> runState (modify (+1)) 0
((), 1)
Note that values of type `State s a` are not serializable.
State
runState
s -> (a, s)
- instance
ActionStates(States) - instance
Action(States) - instance
Applicative(States) - instance
GetFieldrunState(Statesa) (s-> (a,s)) - instance
SetFieldrunState(Statesa) (s-> (a,s)) - instance
Functor(States)
Functions
evalState
evalState : State s a -> s -> a
Special case of runState that does not return the final state.
execState
execState : State s a -> s -> s
Special case of runState that does only retun the final state.
Orphan Typeclass Instances
-
instance
Functor(States) -
instance
Applicative(States) -
instance
Action(States) -
instance
ActionStates(States)