Copyright | (c) 2023 Sayo contributors |
---|---|
License | MPL-2.0 (see the LICENSE file) |
Maintainer | ymdfield@outlook.jp |
Safe Haskell | None |
Language | GHC2021 |
Control.Monad.Hefty.State
Description
Interpreter for the State
effect.
Synopsis
- runState :: forall s (es :: [Effect]) a. FOEs es => s -> Eff (State s ': es) a -> Eff es (s, a)
- evalState :: forall s (es :: [Effect]) a. s -> FOEs es => Eff (State s ': es) a -> Eff es a
- execState :: forall s (es :: [Effect]) a. FOEs es => s -> Eff (State s ': es) a -> Eff es s
- handleState :: forall s (f :: Type -> Type) g ans x. State s f x -> s -> (s -> x -> g ans) -> g ans
- transactState :: forall s (es :: [Effect]) a. (State s :> es, FOEs es) => Eff es a -> Eff es a
- runStateNaive :: forall s (es :: [Effect]) a. FOEs es => s -> Eff (State s ': es) a -> Eff es (s, a)
- module Data.Effect.State
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.
module Data.Effect.State