HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulefused-effects-1.1.2.7Haskell2010

Control.Effect.Lift

Provides a mechanism to kick off the evaluation of an effect stack that takes place in a monadic context.

Lift effects are always the last effect in a given effect stack. These stacks are invoked with runM or run.

Predefined carriers:

  • 2 types
  • 1 class
  • 4 values

Lift effect

4 declarations
valuesendM :: (Has (Lift n) sig m, Functor n) => n a -> m a
#

Given a Lift n constraint in a signature carried by m, sendM promotes arbitrary actions of type n a to m a. It is spiritually similar to lift from the MonadTrans typeclass.

valuesendIO :: Has (Lift IO) sig m => IO a -> m a
#

A type-restricted variant of sendM for IO actions.

This is particularly useful when you have a Has (Lift IO) sig m constraint for the use of liftWith, and want to run an action abstracted over MonadIO. IO has a MonadIO instance, and sendIO’s type restricts the action’s type to IO without further type annotations.

valueliftWith
  1. :: Has (Lift n) sig m
  2. => forall (ctx :: Type -> Type). Functor ctx => Handler ctx m n -> ctx () -> n (ctx a)
  3. -> m a
#

Run actions in an outer context.

This can be used to provide interoperation with base functionality like Control.Exception.catch:

liftWith $ \ hdl ctx -> catch (hdl (m <$ ctx)) (hdl . (<$ ctx) . h)

The higher-order function takes both an initial context, and a handler phrased as a distributive law (as described in the documentation for Handler). This handler takes actions lifted into a context functor, which can be either the initial context, or the derived context produced by handling a previous action.

As with MonadBaseControl, care must be taken when lifting functions like Control.Exception.finally which don’t use the return value of one of their actions, as this can lead to dropped effects.

Re-exports

3 declarations
classclass Monad m => Algebra (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) | m -> sig where
#

The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the alg method.

Instances53Algebra, …
typetype Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m)
#

m is a carrier for sig containing eff.

Note that if eff is a sum, it will be decomposed into multiple Member constraints. While this technically allows one to combine multiple unrelated effects into a single Has constraint, doing so has two significant drawbacks:

  1. Due to a problem with recursive type families, this can lead to significantly slower compiles.

  2. It defeats ghc’s warnings for redundant constraints, and thus can lead to a proliferation of redundant constraints as code is changed.

valuerun :: Identity a -> a
#

Run an action exhausted of effects to produce its final result value.