heftia-effects
Copyright(c) 2023 Sayo contributors
LicenseMPL-2.0 (see the LICENSE file)
Maintainer[email protected]
Safe HaskellNone
LanguageGHC2021

Control.Monad.Hefty.State

Description

Interpreter for the State effect.

Synopsis

Documentation

evalState :: forall s (es :: [Effect]) a. s -> FOEs es => Eff (State s ': es) a -> Eff es a Source #

Interpret the State effect. Do not include the final state in the return value.

execState :: forall s (es :: [Effect]) a. FOEs es => s -> Eff (State s ': es) a -> Eff es s Source #

Interpret the State effect. Do not include the final result in the return value.

handleState :: forall s (f :: Type -> Type) g ans x. State s f x -> s -> (s -> x -> g ans) -> g ans Source #

A handler function for the State effect.

runState :: forall s (es :: [Effect]) a. FOEs es => s -> Eff (State s ': es) a -> Eff es (s, a) Source #

Interpret the State effect.

runStateNaive :: forall s (es :: [Effect]) a. FOEs es => s -> Eff (State s ': es) a -> Eff es (s, a) Source #

A naive but somewhat slower version of runState that does not use ad-hoc optimizations.

transactState :: forall s (es :: [Effect]) a. (State s :> es, FOEs es) => Eff es a -> Eff es a Source #

Within the given scope, make the state roll back to the beginning of the scope in case of exceptions, etc.