An extensible, type-safe union. The r type parameter is a type-level
list of effects, any one of which may be held within the Union.
Modulepolysemy-1.9.2.0Haskell2010
Polysemy.Internal.Union
- 3 types
- 2 classes
- 20 values
- Packagepolysemy-1.9.2.0
- Exports27
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceUnion.hs
Polysemy's core type that stores effect values together with information about the higher-order interpretation state of its construction site.
Constructors
Weaving :: Functor f => e (Sem rInitial) a -> f () -> (forall x. f (Sem rInitial x) -> mAfter (f x)) -> (f a -> resultType) -> (forall x. f x -> Maybe x) -> Weaving e mAfter resultTypeweaveEffect :: e (Sem rInitial) aweaveState :: f ()weaveDistrib :: forall x. f (Sem rInitial x) -> mAfter (f x)Distribute
fby transformingSem rInitialintomAfter. This is usually of the formf (Sem (Some ': Effects ': r) x) -> Sem r (f x)weaveResult :: f a -> resultTypeweaveInspect :: forall x. f x -> Maybe x
This class indicates that an effect must be present in the caller's stack. It is the main mechanism by which a program defines its effect dependencies.
Building Unions
4 declarationsLift an effect e into a Union capable of holding it.
Lift an effect e into a Union capable of holding it,
given an explicit proof that the effect exists in r
Weaken a Union so it is capable of storing a new sort of effect at the head.
Using Unions
6 declarationsDecompose a Union. Either this union contains an effect e---the head
of the r list---or it doesn't.
Attempt to take an e effect out of a Union.
Attempt to take an e effect out of a Union, given an explicit
proof that the effect exists in r.
Retrieve the last effect in a Union.
An empty union contains nothing, so this function is uncallable.
Like decomp, but allows for a more efficient
Polysemy.Interpretation.reinterpret function.
Witnesses
5 declarationsA proof that e is an element of r.
Due to technical reasons, ElemOf e r is not powerful enough to
prove Member e r; however, it can still be used send actions of e
into r by using subsumeUsing.
Given Member e r, extract a proof that e is an element of r.
Checks if two membership proofs are equal. If they are, then that means that the effects for which membership is proven must also be equal.
Checking membership
7 declarationsExtracts a proof that e is an element of r if that
is indeed the case; otherwise returns Nothing.
Extends a proof that e is an element of r to a proof that e is an
element of the concatenation of the lists l and r.
l must be specified as a singleton list proof.
Extends a proof that e is an element of l to a proof that e is an
element of the concatenation of the lists l and r.
Extends a proof that e is an element of left <> right to a proof that
e is an element of left <> mid <> right.
Both left and right must be specified as singleton list proofs.
Weaken a Union so it is capable of storing a number of new effects at the head, specified as a singleton list proof.
Weaken a Union so it is capable of storing a number of new effects somewhere within the previous effect list. Both the prefix and the new effects are specified as singleton list proofs.