Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data State s (m :: * -> *) k
- get :: (Member (State s) sig, Carrier sig m) => m s
- gets :: (Member (State s) sig, Carrier sig m) => (s -> a) -> m a
- put :: (Member (State s) sig, Carrier sig m) => s -> m ()
- modify :: (Member (State s) sig, Carrier sig m) => (s -> s) -> m ()
- modifyLazy :: (Member (State s) sig, Carrier sig m) => (s -> s) -> m ()
Documentation
get :: (Member (State s) sig, Carrier sig m) => m s Source #
Get the current state value.
snd (run (runState a get)) == a
gets :: (Member (State s) sig, Carrier sig m) => (s -> a) -> m a Source #
Project a function out of the current state value.
snd (run (runState a (gets (applyFun f)))) == applyFun f a
put :: (Member (State s) sig, Carrier sig m) => s -> m () Source #
Replace the state value with a new value.
fst (run (runState a (put b))) == b
snd (run (runState a (get <* put b))) == a
snd (run (runState a (put b *> get))) == b