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
- Packagefused-effects-1.1.2.7
- Exports7
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceLabelled.hs
An effect transformer turning effects into labelled effects, and a carrier transformer turning carriers into labelled carriers for the same (labelled) effects.
Constructors
Labelled (sub m a)
Instances12LabelledMember, Algebra, MonadTrans, Monad, Functor, MonadFix, …
LabelledMember label l (Labelled label l :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledLeft-occurrence: if
tis at the head of a signature, we can inject it in O(1).LabelledMember label t (Labelled label t)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledReflexivity:
tis a member of itself.Algebra (eff :+: sig) (sub m) => Algebra (Labelled label eff :+: sig) (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadTrans sub => MonadTrans (Labelled label sub)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonad (sub m) => Monad (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledFunctor (sub m) => Functor (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadFix (sub m) => MonadFix (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadFail (sub m) => MonadFail (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledApplicative (sub m) => Applicative (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledAlternative (sub m) => Alternative (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadPlus (sub m) => MonadPlus (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadIO (sub m) => MonadIO (Labelled label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.Labelled
class LabelledMember (label :: k) (sub :: (Type -> Type) -> Type -> Type) (sup :: (Type -> Type) -> Type -> Type) | label sup -> sub whereThe class of labelled types present in a signature.
Methods
injLabelled :: Labelled label sub m a -> sup m aInject 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.LabelledLeft-occurrence: if
tis 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.LabelledRight-recursion: if
tis a member ofr, we can inject it intorin O(n), followed by lifting that intol :+: rin O(1).LabelledMember label t (l1 :+: (l2 :+: r)) => LabelledMember label t ((l1 :+: l2) :+: r)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledLabelledMember label t (Labelled label t)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledReflexivity:
tis a member of itself.
type 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.
Construct a request for a labelled effect to be interpreted by some handler later on.
newtype UnderLabel (label :: k) (sub :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) aA transformer to lift effectful actions to labelled effectful actions.
Constructors
UnderLabel (m a)
Instances10Algebra, MonadTrans, Monad, Functor, MonadFix, MonadFail, …
(LabelledMember label sub sig, Algebra sig m) => Algebra (sub :+: sig) (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadTrans (UnderLabel sub label)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonad m => Monad (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledFunctor m => Functor (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadFix m => MonadFix (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadFail m => MonadFail (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledApplicative m => Applicative (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledAlternative m => Alternative (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadPlus m => MonadPlus (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.LabelledMonadIO m => MonadIO (UnderLabel label sub m)Defined in fused-effects-1.1.2.7 · Control.Effect.Labelled
module Control.Algebra