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.Carrier.Interpret

Provides an InterpretC carrier capable of interpreting an arbitrary effect using a passed-in higher order function to interpret that effect. This is suitable for prototyping new effects quickly.

  • 3 types
  • 2 classes
  • 3 values

Interpret carrier

5 declarations
valuerunInterpret
  1. :: forall (ctx :: Type -> Type) (n :: Type -> Type) x. Functor ctx => Handler ctx n m -> eff n x -> ctx () -> m (ctx x)
  2. -> forall s. Reifies s (Interpreter eff m) => InterpretC s eff m a
  3. -> m a
#

Interpret an effect using a higher-order function.

Note that due to the higher-rank type, you have to use either $ or explicit application when applying this interpreter. That is, you will need to write runInterpret f (runInterpret g myPrgram) or runInterpret f $ runInterpret g $ myProgram. If you try and write runInterpret f . runInterpret g, you will unfortunately get a rather scary type error!

newtypenewtype InterpretC s (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a
#

Constructors

Instances11MonadTrans, Algebra, Monad, Functor, MonadFix, MonadFail, …
classclass Reifies s a | s -> a where
#
newtypenewtype Interpreter (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type)
#

An Interpreter is a function that interprets effects described by sig into the carrier monad m.

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.