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.Labelled

Labelled effects, allowing flexible disambiguation and dependency of parametric effects.

Among other things, this can be used to:

  • Improve inference by relating parametric effect types to some arbitrary label. This can be used to lift existing effect operations, or to define new ones; cf Control.Effect.Reader.Labelled, Control.Effect.State.Labelled for examples of lifting effect operations into labelled effect operations.

  • Express stronger relationships between an effect and the context it’s run in, e.g. to give an effect shadowing semantics, allowing only one instance of it to be active at a time in a given context.

  • Resolve ambiguous types by relating parameters to a concrete label type.

  • 3 types
  • 1 class
  • 3 values
newtypenewtype Labelled (label :: k) (sub :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a
#

An effect transformer turning effects into labelled effects, and a carrier transformer turning carriers into labelled carriers for the same (labelled) effects.

Constructors

Instances12LabelledMember, Algebra, MonadTrans, Monad, Functor, MonadFix, …
classclass LabelledMember (label :: k) (sub :: (Type -> Type) -> Type -> Type) (sup :: (Type -> Type) -> Type -> Type) | label sup -> sub where
#

The class of labelled types present in a signature.

Methods

  • injLabelled :: Labelled label sub m a -> sup m a

    Inject a member of a signature into the signature.

Instances4LabelledMember
  • LabelledMember label l (Labelled label l :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.Labelled

    Left-occurrence: if t is at the head of a signature, we can inject it in O(1).

  • LabelledMember label l r => LabelledMember label l (l' :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.Labelled

    Right-recursion: if t is a member of r, we can inject it into r in O(n), followed by lifting that into l :+: r in O(1).

  • LabelledMember label t (l1 :+: (l2 :+: r)) => LabelledMember label t ((l1 :+: l2) :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.Labelled

    Left-recursion: if t is a member of l1 :+: l2 :+: r, then we can inject it into (l1 :+: l2) :+: r by injection into a right-recursive signature, followed by left-association.

  • LabelledMember label t (Labelled label t)Defined in fused-effects-1.1.2.7 · Control.Effect.Labelled

    Reflexivity: t is a member of itself.

typetype HasLabelled (label :: k) (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (LabelledMember label eff sig, Algebra sig m)
#

m is a carrier for sig containing eff associated with label.

Note that if eff is a sum, it will not be decomposed into multiple LabelledMember constraints. While this technically is possible, it results in unsolvable constraints, as the functional dependencies in Labelled prevent assocating the same label with multiple distinct effects within a signature.

valuesendLabelled :: HasLabelled label eff sig m => eff m a -> m a
#

Construct a request for a labelled effect to be interpreted by some handler later on.

newtypenewtype UnderLabel (label :: k) (sub :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a
#

A transformer to lift effectful actions to labelled effectful actions.

Constructors

Instances10Algebra, MonadTrans, Monad, Functor, MonadFix, MonadFail, …