Copyright | (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King |
---|---|

License | BSD3 |

Maintainer | Alexis King <lexi.lambda@gmail.com> |

Stability | experimental |

Portability | GHC specific language extensions. |

Safe Haskell | None |

Language | Haskell2010 |

Open unions (type-indexed co-products, i.e. type-indexed sums) for extensible effects All operations are constant-time.

## Synopsis

- 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`

(`State`

`Integer`

) effs =>`Eff`

effs ()

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:

(`Member`

Foo effs,`Member`

Bar effs,`Member`

baz 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 effs`eff`

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 ': ([] :: [Type -> Type])) Source # | |

Defined in Data.OpenUnion | |

LastMember m effs => LastMember m (eff ': effs) Source # | |

Defined in Data.OpenUnion |