| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Union
Description
Extensible type-safe unions.
- data Union f as where
- union :: (Union f as -> c) -> (f a -> c) -> Union f (a : as) -> c
- absurdUnion :: Union f `[]` -> a
- umap :: (forall a. f a -> g a) -> Union f as -> Union g as
- _This :: Prism (Union f (a : as)) (Union f (b : as)) (f a) (f b)
- _That :: Prism (Union f (a : as)) (Union f (a : bs)) (Union f as) (Union f bs)
- class (i ~ RIndex a as) => UElem a as i where
- class (is ~ RImage as bs) => USubset as bs is where
- type OpenUnion = Union Identity
- openUnion :: UElem a as (RIndex a as) => Prism' (OpenUnion as) a
Documentation
A union is parameterized by a universe u, an interpretation f
and a list of labels as. The labels of the union are given by
inhabitants of the kind u; the type of values at any label a ::
u is given by its interpretation f a :: *.
Instances
| (Eq (f a), Eq (Union k f as)) => Eq (Union k f ((:) k a as)) Source | |
| Eq (Union k f ([] k)) Source | |
| (Ord (f a), Ord (Union k f as)) => Ord (Union k f ((:) k a as)) Source | |
| Ord (Union k f ([] k)) Source | |
| (Show (f a), Show (Union k f as)) => Show (Union k f ((:) k a as)) Source | |
| Show (Union k f ([] k)) Source | |
| ((~) (* -> *) f Identity, Exception a, Typeable [*] as, Exception (Union * f as)) => Exception (Union * f ((:) * a as)) Source | |
| (~) (* -> *) f Identity => Exception (Union * f ([] *)) Source |
absurdUnion :: Union f `[]` -> a Source
Since a union with an empty list of labels is uninhabited, we can recover any type from it.