HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleeffectful-core-2.3.0.1Haskell2010

Effectful.Internal.Env

  • 5 types
  • 16 values

The environment

2 declarations
datadata Env (es :: [Effect])
#

A strict (WHNF), thread local, mutable, extensible record indexed by types of kind Effect.

Warning: the environment is a mutable data structure and cannot be simultaneously used from multiple threads under any circumstances.

In order to pass it to a different thread, you need to perform a deep copy with the cloneEnv funtion.

Offers very good performance characteristics for most often performed operations:

  • Extending: O(n), where n is the size of the effect stack.

  • Shrinking: O(1).

  • Indexing via (:>): O(1)

  • Modification of a specific element: O(1).

  • Getting a tail: O(1).

  • Cloning: O(N), where N is the size of the Storage.

Relinker

newtypenewtype Relinker (a :: Effect -> Type) (b :: Effect) where
#

A function for relinking Env objects stored in the handlers and/or making a deep copy of the representation of the effect when cloning the environment.

Constructors

Dispatch

4 declarations
familytype family DispatchOf (e :: Effect) :: Dispatch
#

Dispatch types of effects.

Instances16DispatchOf, …

Operations

5 declarations
valuecloneEnv :: Env es -> IO (Env es)
#

Clone the environment to use it in a different thread.

valuerestoreEnv
  1. :: Env es

    Destination.

  2. -> Env es

    Source.

  3. -> IO ()
#

Restore the environment from its clone.

valuetailEnv :: Env (e ': es) -> IO (Env es)
#

Access the tail of the environment.

Modification of the effect stack

valueunconsEnv :: Env (e ': es) -> IO ()
#

Shrink the environment by one data type.

Note: after calling this function e from the input environment is no longer usable.

valueunreplaceEnv :: e :> es => Env es -> IO ()
#

Remove a reference to the replaced effect.

Note: after calling this function the input environment is no longer usable.

valuesubsumeEnv :: e :> es => Env es -> IO (Env (e ': es))
#

Reference an existing effect from the top of the stack.

valueinjectEnv :: Subset xs es => Env es -> IO (Env xs)
#

Construct an environment containing a permutation (with possible duplicates) of a subset of effects from the input environment.

Data retrieval and update