open-signals-0.1.0.3: A mechanism similar to checked exceptions that integrates with MTL and transformer stacks

Safe HaskellNone
LanguageHaskell2010

Data.Union

Description

You probably want to use the Control.Monad.Signal.Class module. This module contains internals.

Synopsis

Documentation

data Union types where Source

An open union type. A Union xs type holds a value of type x where x is some type from xs.

Constructors

Union :: Either (Union types) a -> Union (a : types) 

Instances

(Eq a, Eq (Union as)) => Eq (Union ((:) * a as)) Source 
(Ord a, Ord (Union as)) => Ord (Union ((:) * a as)) Source 
(Read a, Read (Union as)) => Read (Union ((:) * a as)) Source 
Read (Union ([] *)) Source 
(Show a, Show (Union as)) => Show (Union ((:) * a as)) Source 
Show (Union ([] *)) Source 

absurd :: Union `[]` -> a Source

An empty union can't be constructed so we can get any value from it.

class Elem types a where Source

Elem types is a class of types from types. If a is from types it can be lifted into a Union types

Methods

liftSingle :: a -> Union types Source

Instances

Elem as a => Elem ((:) * b as) a Source 
Elem ((:) * a as) a Source 

class Subset as bs where Source

If as is a subset of bs we can take the value of Union as and lift it into Union bs.

Methods

liftUnion :: Union as -> Union bs Source

Instances

Subset ([] *) bs Source 
(Elem bs a, Subset as bs) => Subset ((:) * a as) bs Source 

class All c xs where Source

If all the elements of xs satisfy the c constraint then, given a function that only cares about that constraint type, we can colapse the union into a concrete type.

For example, if all the types in xs satisfy the Show class, then we can use the show function to turn a Union xs into a String.

Methods

deconstructAll :: proxy c -> Union xs -> (forall x. c x => x -> a) -> a Source

Instances

All c ([] *) Source 
(c x, All c xs) => All c ((:) * x xs) Source