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

Control.Monad.Hefty.State

Description

Interpreter for the State effect.

Synopsis

Documentation

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

Interpret the State effect.

evalState :: forall s es 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 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 :: StateHandler s (State s) f g ans Source #

A handler function for the State effect.

transactState :: forall s es 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 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.