heftia-effects-0.7.0.0: higher-order algebraic effects done right
Copyright(c) 2023 Sayo contributors
LicenseMPL-2.0 (see the LICENSE file)
Maintainerymdfield@outlook.jp
Safe HaskellNone
LanguageGHC2021

Control.Monad.Hefty.State

Description

Interpreter for the State effect.

Synopsis

Documentation

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

Interpret the State effect.

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.

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.

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.