HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduleeffectful-core-2.7.1.2GHC2021

Effectful.Dispatch.Static.Primitive

Primitive API for statically dispatched effects.

This module exposes internal implementation details of the Eff monad. Most of the time functions from Effectful.Dispatch.Static are sufficient.

Warning: playing the so called "type tetris" with functions from this module is not enough. Their misuse might lead to data races or internal consistency check failures, so make sure you understand what you're doing.

  • 2 types
  • 11 values

The environment

1 declaration
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 function.

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

Representation of effects

Extending and shrinking

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

Shrink the environment by one data type.

The environment needs to come from consEnv, i.e. the intended usage is bracket (consEnv e f env) unconsEnv.

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

Data retrieval and update

Utils

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

Access the tail of the environment.