in-other-words-0.1.1.0: A higher-order effect system where the sky's the limit
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Carrier

Synopsis

Core types

class Monad m => Carrier m where Source #

The class of effect carriers, and the underlying mechanism with which effects are implemented.

Each carrier is able to implement a number of derived effects, and primitive effects. Users usually only interact with derived effects, as these determine the effects that users have access to.

The standard interpretation tools are typically powerful enough to let you avoid making instances of this class directly. If you need to make your own instance of Carrier, import Control.Effect.Carrier and consult the wiki.

Minimal complete definition

algPrims, reformulate

Associated Types

type Derivs m :: [Effect] Source #

The derived effects that m carries. Each derived effect is eventually reformulated into terms of the primitive effects Prims m or other effects in Derivs m.

In application code, you gain access to effects by placing membership constraints upon Derivs m. You can use Eff or Effs for this purpose.

Although rarely relevant for users, Derivs m can also contain effects that aren't expressed in terms of other effects, as longs as the handlers for those effects can be lifted generically using lift. Such effects don't need to be part of Prims m, which is exclusively for primitive effects whose handlers need special treatment to be lifted.

For example, first order effects such as State never need to be part of Prims m. Certain higher-order effects - such as Cont - can also be handled such that they never need to be primitive.

type Prims m :: [Effect] Source #

The primitive effects that m carries. These are higher-order effects whose handlers aren't expressed in terms of other effects, and thus need to be lifted on a carrier-by-carrier basis.

Never place membership constraints on Prims m. You should only gain access to effects by placing membership constraints on Derivs m.

However, running interpreters may place other kinds of constraints upon Prims m, namely threading constraints, marked by the use of Threaders. If you want to run such an effect interpreter inside application code, you have to propagate such threading constraints through your application.

Prims m should only contain higher-order effects that can't be lifted generically using lift. Any other effects can be placed in Derivs m.

Methods

algPrims :: Algebra' (Prims m) m a Source #

An m-based Algebra (i.e effect handler) over the union of the primitive effects: effects that aren't formulated in terms of other effects. See Prims.

reformulate :: Monad z => Reformulation' (Derivs m) (Prims m) m z a Source #

Any Carrier m must provide a way to describe the derived effects it carries in terms of the primitive effects.

reformulate is that decription: given any monad z such that z lifts m, then a z-based Algebra (i.e. effect handler) over the derived effects can be created out of a z-based Algebra over the primitive effects.

algDerivs :: Algebra' (Derivs m) m a Source #

An m-based algebra (i.e. effect handler) over the union of derived effects (see Derivs m).

This is what send makes use of.

algDerivs is subject to the law:

algDerivs = reformulate id algPrims

which serves as the default implementation.

Instances

Instances details
Carrier Identity Source # 
Instance details

Defined in Control.Effect.Internal

Associated Types

type Derivs Identity :: [Effect] Source #

type Prims Identity :: [Effect] Source #

(Carrier m, Threads ListT (Prims m)) => Carrier (NonDetC m) Source # 
Instance details

Defined in Control.Effect.Internal.NonDet

Associated Types

type Derivs (NonDetC m) :: [Effect] Source #

type Prims (NonDetC m) :: [Effect] Source #

(Carrier m, Threads ListT (Prims m)) => Carrier (CullCutC m) Source # 
Instance details

Defined in Control.Effect.Internal.NonDet

Associated Types

type Derivs (CullCutC m) :: [Effect] Source #

type Prims (CullCutC m) :: [Effect] Source #

(Carrier m, Threads ListT (Prims m)) => Carrier (LogicC m) Source # 
Instance details

Defined in Control.Effect.Internal.NonDet

Associated Types

type Derivs (LogicC m) :: [Effect] Source #

type Prims (LogicC m) :: [Effect] Source #

(Monad m, Carrier (InterpretSimpleC Fail m)) => Carrier (InterpretFailSimpleC m) Source # 
Instance details

Defined in Control.Effect.Fail

Associated Types

type Derivs (InterpretFailSimpleC m) :: [Effect] Source #

type Prims (InterpretFailSimpleC m) :: [Effect] Source #

(Monad m, Carrier (InterpretSimpleC Alt m)) => Carrier (InterpretAltSimpleC m) Source # 
Instance details

Defined in Control.Effect.Alt

Associated Types

type Derivs (InterpretAltSimpleC m) :: [Effect] Source #

type Prims (InterpretAltSimpleC m) :: [Effect] Source #

Carrier m => Carrier (Ap m) Source # 
Instance details

Defined in Control.Effect.Internal

Associated Types

type Derivs (Ap m) :: [Effect] Source #

type Prims (Ap m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (Ap m)) (Ap m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (Ap m)) (Prims (Ap m)) (Ap m) z a Source #

algDerivs :: Algebra' (Derivs (Ap m)) (Ap m) a Source #

Carrier m => Carrier (Alt m) Source # 
Instance details

Defined in Control.Effect.Internal

Associated Types

type Derivs (Alt m) :: [Effect] Source #

type Prims (Alt m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (Alt m)) (Alt m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (Alt m)) (Prims (Alt m)) (Alt m) z a Source #

algDerivs :: Algebra' (Derivs (Alt m)) (Alt m) a Source #

Carrier m => Carrier (IdentityT m) Source # 
Instance details

Defined in Control.Effect.Internal

Associated Types

type Derivs (IdentityT m) :: [Effect] Source #

type Prims (IdentityT m) :: [Effect] Source #

Carrier m => Carrier (Itself m) Source # 
Instance details

Defined in Control.Effect.Internal

Associated Types

type Derivs (Itself m) :: [Effect] Source #

type Prims (Itself m) :: [Effect] Source #

Carrier (CompositionBaseT ts m) => Carrier (CompositionC ts m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type Derivs (CompositionC ts m) :: [Effect] Source #

type Prims (CompositionC ts m) :: [Effect] Source #

Carrier m => Carrier (Effly m) Source # 
Instance details

Defined in Control.Effect.Internal.Effly

Associated Types

type Derivs (Effly m) :: [Effect] Source #

type Prims (Effly m) :: [Effect] Source #

(Threads (ReaderT (ReifiedPrimHandler e m)) (Prims m), ThreadsEff (ReaderT (ReifiedPrimHandler e m)) e, RepresentationalEff e, Carrier m) => Carrier (InterpretPrimSimpleC e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type Derivs (InterpretPrimSimpleC e m) :: [Effect] Source #

type Prims (InterpretPrimSimpleC e m) :: [Effect] Source #

(Threads (ReaderT (ReifiedHandler e m)) (Prims m), RepresentationalEff e, Carrier m) => Carrier (InterpretSimpleC e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type Derivs (InterpretSimpleC e m) :: [Effect] Source #

type Prims (InterpretSimpleC e m) :: [Effect] Source #

Carrier m => Carrier (EmbedC m) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type Derivs (EmbedC m) :: [Effect] Source #

type Prims (EmbedC m) :: [Effect] Source #

Monad m => Carrier (RunMC m) Source # 
Instance details

Defined in Control.Effect.Embed

Associated Types

type Derivs (RunMC m) :: [Effect] Source #

type Prims (RunMC m) :: [Effect] Source #

(Monoid o, Carrier m, Threads (WriterT o) (Prims m)) => Carrier (WriterLazyC o m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type Derivs (WriterLazyC o m) :: [Effect] Source #

type Prims (WriterLazyC o m) :: [Effect] Source #

(Monoid o, Carrier m, Threads (WriterT o) (Prims m)) => Carrier (ListenLazyC o m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type Derivs (ListenLazyC o m) :: [Effect] Source #

type Prims (ListenLazyC o m) :: [Effect] Source #

(Monoid o, Carrier m, Threads (WriterT o) (Prims m)) => Carrier (TellLazyC o m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type Derivs (TellLazyC o m) :: [Effect] Source #

type Prims (TellLazyC o m) :: [Effect] Source #

(Carrier m, Monoid o, Threads (WriterT o) (Prims m)) => Carrier (WriterC o m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type Derivs (WriterC o m) :: [Effect] Source #

type Prims (WriterC o m) :: [Effect] Source #

(Carrier m, Monoid o, Threads (WriterT o) (Prims m)) => Carrier (ListenC o m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type Derivs (ListenC o m) :: [Effect] Source #

type Prims (ListenC o m) :: [Effect] Source #

(Carrier m, Monoid o, Threads (WriterT o) (Prims m)) => Carrier (TellC o m) Source # 
Instance details

Defined in Control.Effect.Internal.Writer

Associated Types

type Derivs (TellC o m) :: [Effect] Source #

type Prims (TellC o m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (TellC o m)) (TellC o m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (TellC o m)) (Prims (TellC o m)) (TellC o m) z a Source #

algDerivs :: Algebra' (Derivs (TellC o m)) (TellC o m) a Source #

Carrier m => Carrier (UnliftC m) Source # 
Instance details

Defined in Control.Effect.Internal.Unlift

Associated Types

type Derivs (UnliftC m) :: [Effect] Source #

type Prims (UnliftC m) :: [Effect] Source #

(Carrier m, Threads (StateT s) (Prims m)) => Carrier (StateLazyC s m) Source # 
Instance details

Defined in Control.Effect.Internal.State

Associated Types

type Derivs (StateLazyC s m) :: [Effect] Source #

type Prims (StateLazyC s m) :: [Effect] Source #

(Carrier m, Threads (StateT s) (Prims m)) => Carrier (StateC s m) Source # 
Instance details

Defined in Control.Effect.Internal.State

Associated Types

type Derivs (StateC s m) :: [Effect] Source #

type Prims (StateC s m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (StateC s m)) (StateC s m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (StateC s m)) (Prims (StateC s m)) (StateC s m) z a Source #

algDerivs :: Algebra' (Derivs (StateC s m)) (StateC s m) a Source #

Carrier m => Carrier (HoistC m) Source # 
Instance details

Defined in Control.Effect.Internal.Regional

Associated Types

type Derivs (HoistC m) :: [Effect] Source #

type Prims (HoistC m) :: [Effect] Source #

(Threads (ReaderT i) (Prims m), Carrier m) => Carrier (ReaderC i m) Source # 
Instance details

Defined in Control.Effect.Internal.Reader

Associated Types

type Derivs (ReaderC i m) :: [Effect] Source #

type Prims (ReaderC i m) :: [Effect] Source #

Carrier m => Carrier (HoistOptionC m) Source # 
Instance details

Defined in Control.Effect.Internal.Optional

Associated Types

type Derivs (HoistOptionC m) :: [Effect] Source #

type Prims (HoistOptionC m) :: [Effect] Source #

(IntroConsistent ('[] :: [Effect]) '[UnwrappedEff e] m, EffNewtype e, Carrier m) => Carrier (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type Derivs (UnwrapTopC e m) :: [Effect] Source #

type Prims (UnwrapTopC e m) :: [Effect] Source #

(Carrier m, Member (UnwrappedEff e) (Derivs m), EffNewtype e) => Carrier (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type Derivs (UnwrapC e m) :: [Effect] Source #

type Prims (UnwrapC e m) :: [Effect] Source #

(Carrier m, Threads (ExceptT e) (Prims m)) => Carrier (ErrorC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Error

Associated Types

type Derivs (ErrorC e m) :: [Effect] Source #

type Prims (ErrorC e m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ErrorC e m)) (ErrorC e m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ErrorC e m)) (Prims (ErrorC e m)) (ErrorC e m) z a Source #

algDerivs :: Algebra' (Derivs (ErrorC e m)) (ErrorC e m) a Source #

(Carrier m, Threads (ExceptT e) (Prims m)) => Carrier (ThrowC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Error

Associated Types

type Derivs (ThrowC e m) :: [Effect] Source #

type Prims (ThrowC e m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ThrowC e m)) (ThrowC e m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ThrowC e m)) (Prims (ThrowC e m)) (ThrowC e m) z a Source #

algDerivs :: Algebra' (Derivs (ThrowC e m)) (ThrowC e m) a Source #

Carrier m => Carrier (BaseControlC m) Source # 
Instance details

Defined in Control.Effect.Internal.BaseControl

Associated Types

type Derivs (BaseControlC m) :: [Effect] Source #

type Prims (BaseControlC m) :: [Effect] Source #

(Carrier m, Threads (ContT r) (Prims m)) => Carrier (ShiftFastC r m) Source # 
Instance details

Defined in Control.Effect.Internal.Cont

Associated Types

type Derivs (ShiftFastC r m) :: [Effect] Source #

type Prims (ShiftFastC r m) :: [Effect] Source #

(Carrier m, Threads (FreeT (ContBase (m r) r)) (Prims m)) => Carrier (ShiftC r m) Source # 
Instance details

Defined in Control.Effect.Internal.Cont

Associated Types

type Derivs (ShiftC r m) :: [Effect] Source #

type Prims (ShiftC r m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ShiftC r m)) (ShiftC r m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ShiftC r m)) (Prims (ShiftC r m)) (ShiftC r m) z a Source #

algDerivs :: Algebra' (Derivs (ShiftC r m)) (ShiftC r m) a Source #

(Carrier m, Threads (ContT r) (Prims m)) => Carrier (ContFastC r m) Source # 
Instance details

Defined in Control.Effect.Internal.Cont

Associated Types

type Derivs (ContFastC r m) :: [Effect] Source #

type Prims (ContFastC r m) :: [Effect] Source #

(Carrier m, Threads (FreeT (ContBase (m r) r)) (Prims m)) => Carrier (ContC r m) Source # 
Instance details

Defined in Control.Effect.Internal.Cont

Associated Types

type Derivs (ContC r m) :: [Effect] Source #

type Prims (ContC r m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ContC r m)) (ContC r m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ContC r m)) (Prims (ContC r m)) (ContC r m) z a Source #

algDerivs :: Algebra' (Derivs (ContC r m)) (ContC r m) a Source #

(Threads (FreeT (FOEff e)) (Prims m), Carrier m) => Carrier (SteppedC e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Stepped

Associated Types

type Derivs (SteppedC e m) :: [Effect] Source #

type Prims (SteppedC e m) :: [Effect] Source #

(FirstOrder e, Carrier m, Threads (ReaderT (ReifiedFOHandler e m)) (Prims m)) => Carrier (InterceptRC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Intercept

Associated Types

type Derivs (InterceptRC e m) :: [Effect] Source #

type Prims (InterceptRC e m) :: [Effect] Source #

Handler h Fail m => Carrier (InterpretFailC h m) Source # 
Instance details

Defined in Control.Effect.Fail

Associated Types

type Derivs (InterpretFailC h m) :: [Effect] Source #

type Prims (InterpretFailC h m) :: [Effect] Source #

Handler h Alt m => Carrier (InterpretAltC h m) Source # 
Instance details

Defined in Control.Effect.Alt

Associated Types

type Derivs (InterpretAltC h m) :: [Effect] Source #

type Prims (InterpretAltC h m) :: [Effect] Source #

(Carrier m, Member e (Derivs m)) => Carrier (SubsumeC e m) Source # 
Instance details

Defined in Control.Effect.Internal

Associated Types

type Derivs (SubsumeC e m) :: [Effect] Source #

type Prims (SubsumeC e m) :: [Effect] Source #

(Carrier m, KnownList top, KnownList new, IntroConsistent top new m) => Carrier (IntroC top new m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Intro

Associated Types

type Derivs (IntroC top new m) :: [Effect] Source #

type Prims (IntroC top new m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (IntroC top new m)) (IntroC top new m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (IntroC top new m)) (Prims (IntroC top new m)) (IntroC top new m) z a Source #

algDerivs :: Algebra' (Derivs (IntroC top new m)) (IntroC top new m) a Source #

(Threads (ReaderT (ReifiedHandler e m)) (Prims m), RepresentationalEff e, KnownList new, HeadEffs new m, Carrier m) => Carrier (ReinterpretSimpleC e new m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type Derivs (ReinterpretSimpleC e new m) :: [Effect] Source #

type Prims (ReinterpretSimpleC e new m) :: [Effect] Source #

(Carrier m, Handler h e m) => Carrier (InterpretC h e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type Derivs (InterpretC h e m) :: [Effect] Source #

type Prims (InterpretC h e m) :: [Effect] Source #

PrimHandler h e m => Carrier (InterpretPrimC h e m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type Derivs (InterpretPrimC h e m) :: [Effect] Source #

type Prims (InterpretPrimC h e m) :: [Effect] Source #

(KnownList l, HeadEffs l m) => Carrier (UnionC l m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type Derivs (UnionC l m) :: [Effect] Source #

type Prims (UnionC l m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (UnionC l m)) (UnionC l m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (UnionC l m)) (Prims (UnionC l m)) (UnionC l m) z a Source #

algDerivs :: Algebra' (Derivs (UnionC l m)) (UnionC l m) a Source #

(Member e' (Derivs m), Coercible e e', Carrier m) => Carrier (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type Derivs (WrapC e e' m) :: [Effect] Source #

type Prims (WrapC e e' m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (WrapC e e' m)) (WrapC e e' m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (WrapC e e' m)) (Prims (WrapC e e' m)) (WrapC e e' m) z a Source #

algDerivs :: Algebra' (Derivs (WrapC e e' m)) (WrapC e e' m) a Source #

Carrier (t (u m)) => Carrier (ComposeT t u m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Compose

Associated Types

type Derivs (ComposeT t u m) :: [Effect] Source #

type Prims (ComposeT t u m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ComposeT t u m)) (ComposeT t u m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ComposeT t u m)) (Prims (ComposeT t u m)) (ComposeT t u m) z a Source #

algDerivs :: Algebra' (Derivs (ComposeT t u m)) (ComposeT t u m) a Source #

(Handler h e m, Carrier m, KnownList new, IntroConsistent ('[] :: [Effect]) new m) => Carrier (ReinterpretC h e new m) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type Derivs (ReinterpretC h e new m) :: [Effect] Source #

type Prims (ReinterpretC h e new m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ReinterpretC h e new m)) (ReinterpretC h e new m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ReinterpretC h e new m)) (Prims (ReinterpretC h e new m)) (ReinterpretC h e new m) z a Source #

algDerivs :: Algebra' (Derivs (ReinterpretC h e new m)) (ReinterpretC h e new m) a Source #

(KnownList b, Eff (Union b) m) => Carrier (UnionizeC b m) Source # 
Instance details

Defined in Control.Effect.Union

Associated Types

type Derivs (UnionizeC b m) :: [Effect] Source #

type Prims (UnionizeC b m) :: [Effect] Source #

Eff (Exceptional eff exc) m => Carrier (ExceptionallyC eff exc m) Source # 
Instance details

Defined in Control.Effect.Exceptional

Associated Types

type Derivs (ExceptionallyC eff exc m) :: [Effect] Source #

type Prims (ExceptionallyC eff exc m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (ExceptionallyC eff exc m)) (ExceptionallyC eff exc m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (ExceptionallyC eff exc m)) (Prims (ExceptionallyC eff exc m)) (ExceptionallyC eff exc m) z a Source #

algDerivs :: Algebra' (Derivs (ExceptionallyC eff exc m)) (ExceptionallyC eff exc m) a Source #

(Reifies sHandler (HandlerCState p m z), Reifies sReform (ReifiedReformulation r p m), Monad z) => Carrier (HandlerC sHandler sReform r p m z) Source # 
Instance details

Defined in Control.Effect.Carrier.Internal.Interpret

Associated Types

type Derivs (HandlerC sHandler sReform r p m z) :: [Effect] Source #

type Prims (HandlerC sHandler sReform r p m z) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (HandlerC sHandler sReform r p m z)) (HandlerC sHandler sReform r p m z) a Source #

reformulate :: Monad z0 => Reformulation' (Derivs (HandlerC sHandler sReform r p m z)) (Prims (HandlerC sHandler sReform r p m z)) (HandlerC sHandler sReform r p m z) z0 a Source #

algDerivs :: Algebra' (Derivs (HandlerC sHandler sReform r p m z)) (HandlerC sHandler sReform r p m z) a Source #

Carrier m => Carrier (GainBaseControlC b z m) Source # 
Instance details

Defined in Control.Effect.BaseControl

Associated Types

type Derivs (GainBaseControlC b z m) :: [Effect] Source #

type Prims (GainBaseControlC b z m) :: [Effect] Source #

type Algebra r m = forall x. Union r m x -> m x Source #

An Algebra r m desribes a collection of effect handlers for m over all effects in the list r.

type Algebra' r m a = Union r m a -> m a Source #

A first-rank type which can often be used instead of Algebra

type Reformulation r p m = forall z. Monad z => (forall x. m x -> z x) -> Algebra p z -> Algebra r z Source #

The type of reformulate.

A Reformulation r p m describes how the derived effects r are formulated in terms of the primitive effects p and first-order operations of m. This is done by providing an Algebra r z for any monad z that lifts m and implements an Algebra over p.

type Reformulation' r p m z a = (forall x. m x -> z x) -> Algebra p z -> Algebra' r z a Source #

A less higher-rank variant of Reformulation, which is sometimes important.

Combinators for Algebras

powerAlg :: forall e r m a. RepresentationalEff e => Algebra' r m a -> (e m a -> m a) -> Algebra' (e ': r) m a Source #

Strengthen an Algebra by providing a handler for a new effect e.

powerAlg' :: forall e r m a. Algebra' r m a -> (forall z. Coercible z m => e z a -> m a) -> Algebra' (e ': r) m a Source #

weakenAlg :: Algebra' (e ': r) m a -> Algebra' r m a Source #

Weaken an Algebra by removing the topmost effect.

coerceAlg :: forall n m e a b. (Coercible n m, RepresentationalEff e) => (e m a -> m b) -> e n a -> n b Source #

Combinators for Reformulations

liftReform :: (MonadTrans t, Monad m) => Reformulation' r p m z a -> Reformulation' r p (t m) z a Source #

Lift an m-based Reformulation to a t m-based Reformulation, where t is any MonadTrans

addDeriv :: (RepresentationalEff e, Monad m) => (forall z x. (Carrier z, Derivs z ~ r, Prims z ~ p, MonadBase m z) => e (Effly z) x -> Effly z x) -> Reformulation r p m -> Reformulation (e ': r) p m Source #

Add a derived effect to a Reformulation by providing a handler for that effect.

The handler is an EffHandler, but with derived and primitive effects determined by the transformed Reformulation.

addPrim :: forall e r p m z a. Monad z => Reformulation' r p m z a -> Reformulation' (e ': r) (e ': p) m z a Source #

Add a primitive effect and corresponding derived effect to a Reformulation.

weakenReform :: Reformulation' (e ': r) p m z a -> Reformulation' r p m z a Source #

Weaken a Reformulation by removing the topmost derived effect.

weakenReformUnder1 :: forall e' e r p m z a. Reformulation' (e ': (e' ': r)) p m z a -> Reformulation' (e ': r) p m z a Source #

Weaken a Reformulation by removing a derived effect under the topmost effect.

weakenReformUnder :: forall new e r p m z a. KnownList new => Reformulation' (e ': Append new r) p m z a -> Reformulation' (e ': r) p m z a Source #

Weaken a Reformulation by removing a number of derived effects under the topmost effect.

This needs a type application to specify what effects to remove.

weakenReformUnderMany :: forall top new r p m z a. (KnownList top, KnownList new) => Reformulation' (Append top (Append new r)) p m z a -> Reformulation' (Append top r) p m z a Source #

Weaken a Reformulation by removing a number of derived effects under a number of topmost effects.

This needs a type application to specify the top effects of the stack underneath which effects are removed, and another type application to specify what effects to remove.

For example:

weakenReformUnderMany @'[Catch e] @'[Optional ((->) e)]
  :: Reformulation (Catch e ': Optional ((->) e) ': r) p m
  -> Reformulation (Catch e ': r) p m

coerceReform :: Coercible m n => Reformulation' r p m z a -> Reformulation' r p n z a Source #

Hiding effects

type family StripPrefix xs r where ... Source #

Remove the prefix xs from the list r.

IntroC, ReinterpretC and friends don't as much introduce effects as they hide them, through removing effects from the derived effects that the transformed carrier carries. This is done thorugh StripPrefix.

For example:

   Derivs (ReinterpretSimpleC e '[newE, newE2])
 = e ': StripPrefix '[newE, newE2] (Derivs m)

Equations

StripPrefix '[] r = r 
StripPrefix (x ': xs) (x ': r) = StripPrefix xs r 

Type Coercion

Common classes for newtype deriving

Primitive effects

Union