HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulefused-effects-1.1.2.7Haskell2010

Control.Carrier.State.Lazy

A carrier for the State effect that refrains from evaluating its state until necessary. This is less efficient than Control.Carrier.State.Strict but allows some cyclic computations to terminate that would loop infinitely in a strict state carrier.

Note that the parameter order in runState, evalState, and execState is reversed compared the equivalent functions provided by transformers. This is an intentional decision made to enable the composition of effect handlers with . without invoking flip.

  • 1 type
  • 3 values

Lazy state carrier

4 declarations
valuerunState :: s -> StateC s m a -> m (s, a)
#

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.

runState s (pure a) = pure (s, a)
runState s get = pure (s, s)
runState s (put t) = pure (t, ())
newtypenewtype StateC s (m :: Type -> Type) a
#

Constructors

Instances10MonadTrans, Monad, Functor, MonadFix, MonadFail, Applicative, …

State effect

0 declarations