Union Types for Haskell!?

Christian Lescher christian@lescher.de
Fri, 24 Nov 2000 19:02:11 +0100


Hi Bernd,

>   data B = ...
>   data C = ...
>   type A = B | C | D -- A accepts values of either B or C or D (cf. the
> "Either a" type in the Prelude)

What about the construction of a union type in Haskell like this?:

  data B = B1 | B2
  data C = C1 | C2 | C3
  data D = D1 | D2
  data A = UB B | UC C | UD D -- here's the union type

For instance a list of type [A] may look like this: [UB B1,UC C2,UC C1,UD D1]

Christian