| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Effect.State.Lazy
Synopsis
- module Control.Effect.State.Internal
- runState :: s -> StateC s m a -> m (s, a)
- evalState :: forall s m a. Functor m => s -> StateC s m a -> m a
- execState :: forall s m a. Functor m => s -> StateC s m a -> m s
- newtype StateC s m a = StateC {
- runStateC :: s -> m (s, a)
- class (HFunctor sig, Monad m) => Carrier sig m | m -> sig
- run :: PureC a -> a
State effect
Lazy state carrier
runState :: s -> StateC s m a -> m (s, a) Source #
Run a lazy State effect, yielding the result value and the final state.
More programs terminate with lazy state than strict state, but injudicious
use of lazy state may lead to thunk buildup.
run (runState a (pure b)) === (a, b)
take 5 . snd . run $ runState () (traverse pure [1..]) === [1,2,3,4,5]
evalState :: forall s m a. Functor m => s -> StateC s m a -> m a Source #
Run a lazy State effect, yielding the result value and discarding the final state.
run (evalState a (pure b)) === b
execState :: forall s m a. Functor m => s -> StateC s m a -> m s Source #
Run a lazy State effect, yielding the final state and discarding the return value.
run (execState a (pure b)) === a
Instances
| MonadTrans (StateC s) Source # | |
Defined in Control.Effect.State.Lazy | |
| Monad m => Monad (StateC s m) Source # | |
| Functor m => Functor (StateC s m) Source # | |
| MonadFix m => MonadFix (StateC s m) Source # | |
Defined in Control.Effect.State.Lazy | |
| MonadFail m => MonadFail (StateC s m) Source # | |
Defined in Control.Effect.State.Lazy | |
| (Functor m, Monad m) => Applicative (StateC s m) Source # | |
Defined in Control.Effect.State.Lazy | |
| MonadIO m => MonadIO (StateC s m) Source # | |
Defined in Control.Effect.State.Lazy | |
| (Alternative m, Monad m) => Alternative (StateC s m) Source # | |
| (Alternative m, Monad m) => MonadPlus (StateC s m) Source # | |
| (Carrier sig m, Effect sig) => Carrier (State s :+: sig) (StateC s m) Source # | |
Re-exports
class (HFunctor sig, Monad m) => Carrier sig m | m -> sig Source #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the eff method.
Minimal complete definition