| Copyright | (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King |
|---|---|
| License | BSD3 |
| Maintainer | Alexis King <[email protected]> |
| Stability | experimental |
| Portability | GHC specific language extensions. |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.OpenUnion
Description
Open unions (type-indexed co-products, i.e. type-indexed sums) for extensible effects All operations are constant-time.
- data Union (r :: [* -> *]) a
- class Weakens q where
- type family xs :++: ys where ...
- decomp :: Union (t ': r) a -> Either (Union r a) (t a)
- weaken :: Union r a -> Union (any ': r) a
- extract :: Union '[t] a -> t a
- class FindElem eff effs => Member (eff :: * -> *) effs where
- type family Members effs effs' :: Constraint where ...
- class Member m effs => LastMember m effs | effs -> m
Open Union
Open Union Operations
Open Union Membership Constraints
class FindElem eff effs => Member (eff :: * -> *) effs where Source #
A constraint that requires that a particular effect, eff, is a member of
the type-level list effs. This is used to parameterize an
Eff computation over an arbitrary list of effects, so
long as eff is somewhere in the list.
For example, a computation that only needs access to a cell of mutable state
containing an Integer would likely use the following type:
Member(StateInteger) effs =>Effeffs ()
Methods
inj :: eff a -> Union effs a Source #
Takes a request of type t :: * -> *, and injects it into the
Union.
O(1)
Instances
| (FindElem t r, IfNotFound t r r) => Member t r Source # | |
type family Members effs effs' :: Constraint where ... Source #
A shorthand constraint that represents a combination of multiple Member
constraints. That is, the following Members constraint:
Members '[Foo, Bar, Baz] effs
…is equivalent to the following set of Member constraints:
(MemberFoo effs,MemberBar effs,Memberbaz effs)
Note that, since each effect is translated into a separate Member
constraint, the order of the effects does not matter.
class Member m effs => LastMember m effs | effs -> m Source #
Like Member, is a constraint that requires that
LastMember eff effseff is in the type-level list effs. However, unlike Member,
LastMember requires m be the final effect in effs.
Generally, this is not especially useful, since it is preferable for
computations to be agnostic to the order of effects, but it is quite useful
in combination with sendM or
liftBase to embed ordinary monadic effects within an
Eff computation.
Instances
| LastMember m ((:) (* -> *) m ([] (* -> *))) Source # | |
| LastMember m effs => LastMember m ((:) (* -> *) eff effs) Source # | |