fused-effects-1.1.1.0: A fast, flexible, fused effect system.

Control.Carrier.State.Strict

Contents

Description

A carrier for the State effect. It evaluates its inner state strictly, which is the correct choice for the majority of use cases.

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.

Since: 1.0.0.0

Synopsis

# Strict state carrier

runState :: s -> StateC s m a -> m (s, a) Source #

Run a State effect starting from the passed value.

runState s (pure a) = pure (s, a)

runState s get = pure (s, s)

runState s (put t) = pure (t, ())


Since: 1.0.0.0

evalState :: forall s m a. Functor m => s -> StateC s m a -> m a Source #

Run a State effect, yielding the result value and discarding the final state.

evalState s m = fmap snd (runState s m)


Since: 1.0.0.0

execState :: forall s m a. Functor m => s -> StateC s m a -> m s Source #

Run a State effect, yielding the final state and discarding the return value.

execState s m = fmap fst (runState s m)


Since: 1.0.0.0

newtype StateC s m a Source #

Since: 1.0.0.0

Constructors

 StateC (s -> m (s, a))

#### Instances

Instances details