| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Effect.Internal.Intercept
Synopsis
- data Intercept (e :: Effect) :: Effect where
- data InterceptCont (e :: Effect) :: Effect where
- InterceptCont :: Coercible z m => InterceptionMode -> (forall x. (x -> m a) -> e z x -> m a) -> m a -> InterceptCont e m a
- data InterceptionMode
- data InterceptB e a where
- InterceptB :: (forall q x. (x -> a) -> e q x -> a) -> InterceptB e a
- interceptB :: forall e m q a. (FirstOrder e, Eff (Unravel (InterceptB e)) m) => (forall x. (x -> m a) -> e q x -> m a) -> m a -> m a
- type InterceptContC e = CompositionC '[IntroC '[InterceptCont e, Intercept e] '[Unravel (InterceptB e)], InterpretC InterceptH (InterceptCont e), InterpretC InterceptH (Intercept e), InterpretPrimC InterceptH (Unravel (InterceptB e)), SteppedC e]
- data InterceptH
- runInterceptCont :: forall e m a p. (FirstOrder e, Carrier m, Member e (Derivs m), Threaders '[SteppedThreads] m p) => InterceptContC e m a -> m a
- runStateStepped :: forall s m a p. (Carrier m, Threaders '[SteppedThreads] m p) => s -> SteppedC (State s) m a -> m (s, a)
- runTellListStepped :: forall o m a p. (Carrier m, Threaders '[SteppedThreads] m p) => SteppedC (Tell o) m a -> m ([o], a)
- runTellStepped :: forall w m a p. (Monoid w, Carrier m, Threaders '[SteppedThreads] m p) => SteppedC (Tell w) m a -> m (w, a)
- data ListenSteppedH
- type ListenSteppedC w = CompositionC '[ReinterpretC ListenSteppedH (Listen w) '[ListenPrim w], InterpretPrimC ListenSteppedH (ListenPrim w), SteppedC (Tell w)]
- runListenStepped :: forall w m a p. (Monoid w, Carrier m, Threaders '[SteppedThreads] m p) => ListenSteppedC w m a -> m (w, a)
- newtype ReifiedFOHandler e m = ReifiedFOHandler (forall q x. e q x -> m x)
- newtype InterceptRC (e :: Effect) m a = InterceptRC {
- unInterceptRC :: ReaderT (ReifiedFOHandler e m) m a
- runInterceptR :: forall e m a p. (FirstOrder e, Member e (Derivs m), Carrier m, Threaders '[ReaderThreads] m p) => InterceptRC e m a -> m a
Documentation
data Intercept (e :: Effect) :: Effect where Source #
An effect for intercepting actions of a first-order effect.
Even for this library, proper usage of this effect is very complicated. When properly used, this can be a very useful helper effect, allowing you write interpretations for a class of higher-order effects that wouldn't otherwise be possible.
For more information, see the wiki.
Instances
| (FirstOrder e, Eff (Unravel (InterceptB e)) m) => Handler InterceptH (Intercept e) m Source # | |
Defined in Control.Effect.Internal.Intercept Methods effHandler :: EffHandler (Intercept e) m Source # | |
data InterceptCont (e :: Effect) :: Effect where Source #
A variant of InterceptCont that is significantly more powerful, allowing
you to capture the continuation of the program at each use-site of an
effect, as well as aborting execution of the parameter computation
early.
Constructors
| InterceptCont :: Coercible z m => InterceptionMode -> (forall x. (x -> m a) -> e z x -> m a) -> m a -> InterceptCont e m a |
Instances
| (FirstOrder e, Member e (Derivs m), Eff (Unravel (InterceptB e)) m) => Handler InterceptH (InterceptCont e) m Source # | |
Defined in Control.Effect.Internal.Intercept Methods effHandler :: EffHandler (InterceptCont e) m Source # | |
data InterceptionMode Source #
Constructors
| InterceptOne | |
| InterceptAll |
data InterceptB e a where Source #
Constructors
| InterceptB :: (forall q x. (x -> a) -> e q x -> a) -> InterceptB e a |
Instances
| (FirstOrder e, Carrier m, Threaders (SteppedThreads ': ([] :: [[Effect] -> Constraint])) m p) => PrimHandler InterceptH (Unravel (InterceptB e)) (SteppedC e m) Source # | |
Defined in Control.Effect.Internal.Intercept Methods effPrimHandler :: EffPrimHandler (Unravel (InterceptB e)) (SteppedC e m) Source # | |
interceptB :: forall e m q a. (FirstOrder e, Eff (Unravel (InterceptB e)) m) => (forall x. (x -> m a) -> e q x -> m a) -> m a -> m a Source #
type InterceptContC e = CompositionC '[IntroC '[InterceptCont e, Intercept e] '[Unravel (InterceptB e)], InterpretC InterceptH (InterceptCont e), InterpretC InterceptH (Intercept e), InterpretPrimC InterceptH (Unravel (InterceptB e)), SteppedC e] Source #
data InterceptH Source #
Instances
| (FirstOrder e, Member e (Derivs m), Eff (Unravel (InterceptB e)) m) => Handler InterceptH (InterceptCont e) m Source # | |
Defined in Control.Effect.Internal.Intercept Methods effHandler :: EffHandler (InterceptCont e) m Source # | |
| (FirstOrder e, Eff (Unravel (InterceptB e)) m) => Handler InterceptH (Intercept e) m Source # | |
Defined in Control.Effect.Internal.Intercept Methods effHandler :: EffHandler (Intercept e) m Source # | |
| (FirstOrder e, Carrier m, Threaders (SteppedThreads ': ([] :: [[Effect] -> Constraint])) m p) => PrimHandler InterceptH (Unravel (InterceptB e)) (SteppedC e m) Source # | |
Defined in Control.Effect.Internal.Intercept Methods effPrimHandler :: EffPrimHandler (Unravel (InterceptB e)) (SteppedC e m) Source # | |
runInterceptCont :: forall e m a p. (FirstOrder e, Carrier m, Member e (Derivs m), Threaders '[SteppedThreads] m p) => InterceptContC e m a -> m a Source #
Run , Intercept e and InterceptCont ee effects, provided
that e is first-order and also part of the remaining effect stack.
There are three very important things to note here:
emust be first-order.- Any action of
emade by a handler run afterrunInterceptContwon't get be intercepted. What this means is that you typically want to run the handler foreimmediately afterrunInterceptCont. - This imposes the very restrictive primitive effect
Unravel. Most notably, neitherStateThreadsnorWriterThreadsaccepts it. Because of that, this module offers various alternatives of several commonStateandTellinterpreters with threading constraints that do acceptUnravel.
Derivs(InterceptContCe m) =InterceptConte ':Intercepte ': e ': Derivs m
Prims(InterceptContCe m) =Unravel(InterceptB e) ':Primsm
runStateStepped :: forall s m a p. (Carrier m, Threaders '[SteppedThreads] m p) => s -> SteppedC (State s) m a -> m (s, a) Source #
A variant of runState with a SteppedThreads threading constraint
instead of a StateThreads threading constraint.
runTellListStepped :: forall o m a p. (Carrier m, Threaders '[SteppedThreads] m p) => SteppedC (Tell o) m a -> m ([o], a) Source #
A variant of runTell with a SteppedThreads threading constraint
instead of a StateThreads threading constraint.
runTellStepped :: forall w m a p. (Monoid w, Carrier m, Threaders '[SteppedThreads] m p) => SteppedC (Tell w) m a -> m (w, a) Source #
A variant of runTell with a SteppedThreads threading constraint
instead of a StateThreads threading constraint.
data ListenSteppedH Source #
Instances
| Eff (ListenPrim w) m => Handler ListenSteppedH (Listen w) m Source # | |
Defined in Control.Effect.Internal.Intercept Methods effHandler :: EffHandler (Listen w) m Source # | |
| (Monoid w, Carrier m, Threaders (SteppedThreads ': ([] :: [[Effect] -> Constraint])) m p) => PrimHandler ListenSteppedH (ListenPrim w) (SteppedC (Tell w :: (Type -> Type) -> Type -> Type) m) Source # | |
Defined in Control.Effect.Internal.Intercept Methods effPrimHandler :: EffPrimHandler (ListenPrim w) (SteppedC (Tell w) m) Source # | |
type ListenSteppedC w = CompositionC '[ReinterpretC ListenSteppedH (Listen w) '[ListenPrim w], InterpretPrimC ListenSteppedH (ListenPrim w), SteppedC (Tell w)] Source #
runListenStepped :: forall w m a p. (Monoid w, Carrier m, Threaders '[SteppedThreads] m p) => ListenSteppedC w m a -> m (w, a) Source #
A variant of runListen with a SteppedThreads threading constraint
instead of a StateThreads threading constraint.
Derivs(ListenSteppedCw m) =Listenw ':Tellw ': Derivs m
Prims(ListenSteppedCw m) =ListenPrimw ': Derivs m
newtype ReifiedFOHandler e m Source #
Constructors
| ReifiedFOHandler (forall q x. e q x -> m x) |
newtype InterceptRC (e :: Effect) m a Source #
Constructors
| InterceptRC | |
Fields
| |
Instances
runInterceptR :: forall e m a p. (FirstOrder e, Member e (Derivs m), Carrier m, Threaders '[ReaderThreads] m p) => InterceptRC e m a -> m a Source #
Run and Intercept ee effects, provided
e is first-order and part of the effect stack.
runInterceptR differs from runInterceptCont in four different ways:
- It doesn't handle
InterceptCont. - It has the significantly less restrictive threading constraint
ReaderThreadsinstead ofSteppedThreads - It imposes the significantly more restrictive primitive effect
Unliftinstead ofUnravel. - It is significantly faster.
There are some interpreters -- such as bracketToIO and concToIO --
that runInterceptCont can't be used together with in any capacity
due to its SteppedThreads threading constraint. In
these cases, runInterceptR can be used instead.
Derivs(InterceptRCe m) =Intercepte ': e ': 'Derivs m'
Prims(InterceptRCe m) =Unlift(ReaderT (ReifiedFOHandler e m)) ': 'Derivs m'