
2 Sep
2012
2 Sep
'12
5:06 p.m.
On Sun, Sep 2, 2012 at 9:40 AM,
The thing is, that one ALWAYS wants to create a union of types, and not merely an ad-hock list of data declarations. So why does it take more code to do "the right thing(tm)" than to do "the wrong thing(r)"?
Because a union type is a complex union of parts, and the parts need to be deconstructed in order to be acted upon. There is not a unique way to do this -- different "unwrappings" have different properties and must match your use case. Perhaps you should read "Data types ala carte" (W. Swiestra) [1], which provides an approach to constructing "open" data types (i.e., sum types to which new summands can be added) [1] http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCarte.pdf