HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleeffectful-core-2.3.0.1Haskell2010

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
  • 12 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 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

Representation of effects

Extending and shrinking

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.

Data retrieval and update

Utils

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.