[Haskell-cafe] Polymorphic variants

Dan Doel dan.doel at gmail.com
Thu Aug 2 14:18:40 EDT 2007


On Thursday 02 August 2007, Jon Harrop wrote:
> On Thursday 26 July 2007 00:07:23 Josef Svenningsson wrote:
> > On 7/26/07, Jon Harrop <jon at ffconsultancy.com> wrote:
> > > Does Haskell have anything similar to OCaml's polymorphic variants?
> >
> > No as such, but it's possible to simulate them. As always Oleg was the
> > one to demonstrate how:
> > http://okmij.org/ftp/Haskell/generics.html
>
> Thank you.
>
> Is there any interest in adding polymorphic variants to Haskell? I think it
> is fair to say that OCaml has shown them to be an extremely useful
> construct (more common than objects in OCaml, for example).

I think this topic goes along with the oft-discussed issue of what should be 
done about Haskell's record system. Several of the papers in that area use 
row polymorphism for typing extensible records, and the same thing can be 
used for typing polymorphic variants.

Unfortunately, I guess it's hard to get everyone nailed down on what exactly 
the right solution is (and I guess there are also people who aren't 
interested in scrapping the existing record system), so not much has been 
done outside proposals. To my knowledge, no one has gone as far as 
implementing the proposals yet (which is a requirement for getting into 
Haskell', if that matters), although Hugs reportedly has a record system 
extension that inspired the newer proposals to some extent (I haven't used it 
myself).

-- Dan

P.S.: Some papers:

http://www.cse.ogi.edu/PacSoft/publications/2000/extensiblerecords.pdf

http://research.microsoft.com/users/daan/download/papers/scopedlabels.pdf

The second actually discusses all the operations on variants and whatnot. The 
first just mentions that it's a related topic.


More information about the Haskell-Cafe mailing list