heftia-0.7.0.0: higher-order algebraic effects done right
Copyright(c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King; 2024 Sayo contributors
LicenseMPL-2.0 AND BSD-3-Clause (see the LICENSE and LICENSE.BSD3 files)
Maintainerymdfield@outlook.jp
Safe HaskellNone
LanguageGHC2021

Control.Monad.Hefty.Interpret.State

Description

This module provides an ad-hoc specialized version of Control.Monad.Hefty.Interpret to accelerate interpretations that have a single state type s, especially for effects like State or Writer.

Synopsis

Documentation

type StateHandler s (e :: k -> Type -> Type) (m :: k) (n :: Type -> Type) ans = forall x. e m x -> s -> (s -> x -> n ans) -> n ans Source #

An ad-hoc stateful version of Handler for performance.

Interpretation functions

interpretStateBy :: forall s (e :: Effect) (es :: [Effect]) ans a. (KnownOrder e, FOEs es) => s -> (s -> a -> Eff es ans) -> StateHandler s e (Eff (e ': es)) (Eff es) ans -> Eff (e ': es) a -> Eff es ans Source #

reinterpretStateBy :: forall s (e :: Effect) (es' :: [Effect]) (es :: [Effect]) ans a. (Suffix es es', KnownOrder e, FOEs es) => s -> (s -> a -> Eff es' ans) -> StateHandler s e (Eff (e ': es)) (Eff es') ans -> Eff (e ': es) a -> Eff es' ans Source #

Interposition functions

interposeStateBy :: forall s (e :: Effect) (es :: [Effect]) ans a. (e :> es, FOEs es) => s -> (s -> a -> Eff es ans) -> StateHandler s e (Eff es) (Eff es) ans -> Eff es a -> Eff es ans Source #

interposeStateInBy :: forall s (e :: Effect) (es :: [Effect]) ans a. (In e es, FOEs es) => s -> (s -> a -> Eff es ans) -> StateHandler s e (Eff es) (Eff es) ans -> Eff es a -> Eff es ans Source #

interposeStateForBy :: forall s (e :: Effect) (es :: [Effect]) ans a. (KnownOrder e, FOEs es) => Membership e es -> s -> (s -> a -> Eff es ans) -> StateHandler s e (Eff es) (Eff es) ans -> Eff es a -> Eff es ans Source #