Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
Since: 1.0.2.0
Synopsis
- runLabelled :: forall label sub m a. Labelled label sub m a -> sub m a
- newtype Labelled (label :: k) (sub :: (Type -> Type) -> Type -> Type) m a = Labelled (sub m a)
- class LabelledMember label (sub :: (Type -> Type) -> Type -> Type) sup | label sup -> sub where
- injLabelled :: Labelled label sub m a -> sup m a
- type HasLabelled label eff sig m = (LabelledMember label eff sig, Algebra sig m)
- sendLabelled :: forall label eff sig m a. HasLabelled label eff sig m => eff m a -> m a
- runUnderLabel :: forall label sub m a. UnderLabel label sub m a -> m a
- newtype UnderLabel (label :: k) (sub :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a = UnderLabel (m a)
- module Control.Algebra
Documentation
runLabelled :: forall label sub m a. Labelled label sub m a -> sub m a Source #
Since: 1.0.2.0
newtype Labelled (label :: k) (sub :: (Type -> Type) -> Type -> Type) m a Source #
An effect transformer turning effects into labelled effects, and a carrier transformer turning carriers into labelled carriers for the same (labelled) effects.
Since: 1.0.2.0
Labelled (sub m a) |
Instances
LabelledMember (label :: k) l (Labelled label l :+: r) Source # | Left-occurrence: if |
Defined in Control.Effect.Labelled | |
LabelledMember (label :: k) t (Labelled label t) Source # | Reflexivity: |
Defined in Control.Effect.Labelled | |
(Algebra (eff :+: sig) (sub m), HFunctor eff, HFunctor sig) => Algebra (Labelled label eff :+: sig) (Labelled label sub m) Source # | |
MonadTrans sub => MonadTrans (Labelled label sub) Source # | |
Defined in Control.Effect.Labelled | |
Effect sub => Effect (Labelled label sub) Source # | |
HFunctor sub => HFunctor (Labelled label sub) Source # | |
Monad (sub m) => Monad (Labelled label sub m) Source # | |
Functor (sub m) => Functor (Labelled label sub m) Source # | |
MonadFail (sub m) => MonadFail (Labelled label sub m) Source # | |
Defined in Control.Effect.Labelled | |
Applicative (sub m) => Applicative (Labelled label sub m) Source # | |
Defined in Control.Effect.Labelled pure :: a -> Labelled label sub m a # (<*>) :: Labelled label sub m (a -> b) -> Labelled label sub m a -> Labelled label sub m b # liftA2 :: (a -> b -> c) -> Labelled label sub m a -> Labelled label sub m b -> Labelled label sub m c # (*>) :: Labelled label sub m a -> Labelled label sub m b -> Labelled label sub m b # (<*) :: Labelled label sub m a -> Labelled label sub m b -> Labelled label sub m a # | |
MonadIO (sub m) => MonadIO (Labelled label sub m) Source # | |
Defined in Control.Effect.Labelled | |
Alternative (sub m) => Alternative (Labelled label sub m) Source # | |
MonadPlus (sub m) => MonadPlus (Labelled label sub m) Source # | |
class LabelledMember label (sub :: (Type -> Type) -> Type -> Type) sup | label sup -> sub where Source #
The class of labelled types present in a signature.
Since: 1.0.2.0
injLabelled :: Labelled label sub m a -> sup m a Source #
Inject a member of a signature into the signature.
Since: 1.0.2.0
Instances
LabelledMember label l r => LabelledMember (label :: k) l (l' :+: r) Source # | Right-recursion: if |
Defined in Control.Effect.Labelled | |
LabelledMember (label :: k) l (Labelled label l :+: r) Source # | Left-occurrence: if |
Defined in Control.Effect.Labelled | |
LabelledMember label t (l1 :+: (l2 :+: r)) => LabelledMember (label :: k) t ((l1 :+: l2) :+: r) Source # | Left-recursion: if |
Defined in Control.Effect.Labelled | |
LabelledMember (label :: k) t (Labelled label t) Source # | Reflexivity: |
Defined in Control.Effect.Labelled |
type HasLabelled label eff sig m = (LabelledMember label eff sig, Algebra sig m) Source #
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.
Since: 1.0.2.0
sendLabelled :: forall label eff sig m a. HasLabelled label eff sig m => eff m a -> m a Source #
Construct a request for a labelled effect to be interpreted by some handler later on.
Since: 1.0.2.0
runUnderLabel :: forall label sub m a. UnderLabel label sub m a -> m a Source #
Since: 1.0.2.0
newtype UnderLabel (label :: k) (sub :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a Source #
A transformer to lift effectful actions to labelled effectful actions.
Since: 1.0.2.0
UnderLabel (m a) |
Instances
(LabelledMember label sub sig, HFunctor sub, Algebra sig m) => Algebra (sub :+: sig) (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled alg :: (sub :+: sig) (UnderLabel label sub m) a -> UnderLabel label sub m a Source # | |
MonadTrans (UnderLabel sub label) Source # | |
Defined in Control.Effect.Labelled lift :: Monad m => m a -> UnderLabel sub label m a # | |
Monad m => Monad (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled (>>=) :: UnderLabel label sub m a -> (a -> UnderLabel label sub m b) -> UnderLabel label sub m b # (>>) :: UnderLabel label sub m a -> UnderLabel label sub m b -> UnderLabel label sub m b # return :: a -> UnderLabel label sub m a # | |
Functor m => Functor (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled fmap :: (a -> b) -> UnderLabel label sub m a -> UnderLabel label sub m b # (<$) :: a -> UnderLabel label sub m b -> UnderLabel label sub m a # | |
MonadFail m => MonadFail (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled fail :: String -> UnderLabel label sub m a # | |
Applicative m => Applicative (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled pure :: a -> UnderLabel label sub m a # (<*>) :: UnderLabel label sub m (a -> b) -> UnderLabel label sub m a -> UnderLabel label sub m b # liftA2 :: (a -> b -> c) -> UnderLabel label sub m a -> UnderLabel label sub m b -> UnderLabel label sub m c # (*>) :: UnderLabel label sub m a -> UnderLabel label sub m b -> UnderLabel label sub m b # (<*) :: UnderLabel label sub m a -> UnderLabel label sub m b -> UnderLabel label sub m a # | |
MonadIO m => MonadIO (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled liftIO :: IO a -> UnderLabel label sub m a # | |
Alternative m => Alternative (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled empty :: UnderLabel label sub m a # (<|>) :: UnderLabel label sub m a -> UnderLabel label sub m a -> UnderLabel label sub m a # some :: UnderLabel label sub m a -> UnderLabel label sub m [a] # many :: UnderLabel label sub m a -> UnderLabel label sub m [a] # | |
MonadPlus m => MonadPlus (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled mzero :: UnderLabel label sub m a # mplus :: UnderLabel label sub m a -> UnderLabel label sub m a -> UnderLabel label sub m a # |
module Control.Algebra