Safe Haskell | None |
---|

Original work at: http:okmij.org*ftp*Haskell*extensible*OpenUnion1.hs.
Open unions (type-indexed co-products) for extensible effects.
This implementation relies on _closed_ overlapping instances
(or closed type function overlapping soon to be added to GHC).

- data Union r v
- inj :: (Functor t, Typeable1 t, Member t r) => t v -> Union r v
- prj :: (Typeable1 t, Member t r) => Union r v -> Maybe (t v)
- prjForce :: (Typeable1 t, Member t r) => Union r v -> (t v -> a) -> a
- decomp :: (Typeable1 t, Member t (t :> r)) => Union (t :> r) v -> Either (Union r v) (t v)
- class Member t r
- data a :> b
- unsafeReUnion :: Union r w -> Union t w

# Documentation

Where `r`

is `t1 :> t2 ... :> tn`, `Union r v` can be constructed with a
value of type `ti v`.
Ideally, we should be be able to add the constraint `Member t r`.

prj :: (Typeable1 t, Member t r) => Union r v -> Maybe (t v)Source

Try extracting the contents of a Union as a specific type.

A sum data type, for `composing`

effects
In GHC 7.4, we should make it a list
(:>) :: (* -> *) -> (* -> List) -> List

unsafeReUnion :: Union r w -> Union t wSource

Juggle types for a Union. Use cautiously.