[MLton-user] Wish for a standard sum type

Andreas Rossberg AndreasRossberg@web.de
Mon, 29 May 2006 19:47:49 +0200


"Vesa Karvonen" <vesa.karvonen@cs.helsinki.fi>:
> >
> >   datatype ('a,'b) alt = FST of 'a | SND of 'b
> >
> > although I'm not particularly excited about it. It has the advantage
that it
> > is less likely to collide with user datatype constructors.  (However, I
> > always disliked "either" as a type name, and it reads even worse in
postfix
> > notation ;-) )
>
> FST|SND is not too bad.  I can't say that I like "alt".  How about "sum"?

We tried to find something that has a halfway decent reading in the usual ML
style - at least "int/bool alternative" does not sound substantially worse
than, say, "int option". Speaking of first and second alternative went along
well. We rejected "sum" (and related terminology like inl/inr) because it is
just too technical - you wouldn't call a pair type "product" either. :-)

- Andreas