
15 Sep
2006
15 Sep
'06
7:40 a.m.
On Fri, 15 Sep 2006, Thomas Conway wrote:
Is there any deep and meaningful reason why Haskell doesn't have anonymous discriminated union types?
I'm thinking of an example like:
data Amount = Amount Integer (Mg|G|Kg|T)
Now this particular case is perhaps unconvincing - a seperate Units type would be quite sensible, however I'm thinking of translating ASN.1 definitions into Haskell. ASN.1 allows SEQUENCE (record types) and CHOICE (discriminated unions) as a kind of type constructor.
Not having to invent names for anonymous SEQUENCE and CHOICE types would be nice.
I'm afraid you have to invent these names. Btw. if you want to do more with units, see http://www.haskell.org/hawiki/PhysicalUnits