[Haskell-cafe] Why aren't there anonymous sum types in Haskell?

Alexander Solla alex.solla at gmail.com
Tue Jun 21 22:15:59 CEST 2011


On Tue, Jun 21, 2011 at 12:53 PM, Elliot Stern
<eliyahu.ben.miney at gmail.com>wrote:

> A tuple is basically an anonymous product type.  It's convenient to not
> have to spend the time making a named product type, because product types
> are so obviously useful.
>
>
Tuples are not so anonymous.  Although syntactic sugar complicates the
issue, there is basically a data constructor named (,).


> Is there any reason why Haskell doesn't have anonymous sum types?  If there
> isn't some theoretical problem, is there any practical reason why they
> haven't been implemented?


The problem is that a sum type must "name" the different types, or else it
can't give access to them.  How is a function supposed to know if a value

blah :: A :+: B

is an A or a B?  It seems possible that it could figure it out, but that
problem is undecidable in general.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110621/988a8273/attachment-0001.htm>


More information about the Haskell-Cafe mailing list