Safe Haskell | None |
---|---|
Language | Haskell98 |
Flexible, type-safe open unions.
- data Union s
- class s :< s'
- type family s :\ a
- (@>) :: Typeable a => (a -> b) -> (Union (s :\ a) -> b) -> Union s -> b
- liftUnion :: (Typeable a, `[a]` :< s) => a -> Union s
- reUnion :: s :< s' => Union s -> Union s'
- restrict :: Typeable a => Union s -> Either (Union (s :\ a)) a
- typesExhausted :: Union [] -> a
Documentation
The Union
type - the phantom parameter s
is a list of types
denoting what this Union
might contain.
The value contained is one of those types.
There exists a s :< s'
instance if every type in the list s
can be lifted to s'
.
Remove a type from anywhere in the list.
(@>) :: Typeable a => (a -> b) -> (Union (s :\ a) -> b) -> Union s -> b infixr 2 Source
restrict
in right-fixable style.
typesExhausted :: Union [] -> a Source
Use this in places where all the Union
ed options have been exhausted.