Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- data Union (r :: EffectRow) (m :: Type -> Type) a where
- data Yo e m a where
- type Member e r = Member' e r
- weave :: (Functor s, Functor m, Functor n) => s () -> (forall x. s (m x) -> n (s x)) -> (forall x. s x -> Maybe x) -> Union r m a -> Union r n (s a)
- hoist :: (Functor m, Functor n) => (forall x. m x -> n x) -> Union r m a -> Union r n a
- inj :: forall r e a m. (Functor m, Member e r) => e m a -> Union r m a
- weaken :: forall e r m a. Union r m a -> Union (e ': r) m a
- decomp :: Union (e ': r) m a -> Either (Union r m a) (Yo e m a)
- prj :: forall e r a m. Member e r => Union r m a -> Maybe (Yo e m a)
- extract :: Union '[e] m a -> Yo e m a
- absurdU :: Union '[] m a -> b
- decompCoerce :: Union (e ': r) m a -> Either (Union (f ': r) m a) (Yo e m a)
- data SNat :: Nat -> Type where
- data Nat
- class MemberNoError end r => LastMember end r | r -> end where
- decompLast :: Union r m a -> Either (Union r m a) (Union '[end] m a)

# Documentation

data Union (r :: EffectRow) (m :: Type -> Type) a where Source #

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`

.

type Member e r = Member' e r Source #

A proof that the effect `e`

is available somewhere inside of the effect
stack `r`

.

weave :: (Functor s, Functor m, Functor n) => s () -> (forall x. s (m x) -> n (s x)) -> (forall x. s x -> Maybe x) -> Union r m a -> Union r n (s a) Source #

# Building Unions

inj :: forall r e a m. (Functor m, Member e r) => e m a -> Union r m a Source #

Lift an effect `e`

into a `Union`

capable of holding it.

weaken :: forall e r m a. Union r m a -> Union (e ': r) m a Source #

Weaken a `Union`

so it is capable of storing a new sort of effect.

# Using Unions

decomp :: Union (e ': r) m a -> Either (Union r m a) (Yo e m a) Source #

Decompose a `Union`

. Either this union contains an effect `e`

---the head
of the `r`

list---or it doesn't.

prj :: forall e r a m. Member e r => Union r m a -> Maybe (Yo e m a) Source #

Attempt to take an `e`

effect out of a `Union`

.

absurdU :: Union '[] m a -> b Source #

An empty union contains nothing, so this function is uncallable.

decompCoerce :: Union (e ': r) m a -> Either (Union (f ': r) m a) (Yo e m a) Source #

Like `decomp`

, but allows for a more efficient
`reinterpret`

function.

# Witnesses

data SNat :: Nat -> Type where Source #

A singleton for `Nat`

.

## Instances

TestEquality SNat Source # | |

Defined in Polysemy.Internal.Union |

The kind of type-level natural numbers.

## Instances

TestEquality SNat Source # | |

Defined in Polysemy.Internal.Union |

class MemberNoError end r => LastMember end r | r -> end where Source #

A proof that `end`

is the last effect in the row.

*Since: 0.5.0.0*

## Instances

LastMember end (end ': ([] :: [Effect])) Source # | |

Defined in Polysemy.Internal.Union | |

(LastMember end r, MemberNoError end (eff ': r)) => LastMember end (eff ': r) Source # | |

Defined in Polysemy.Internal.Union |