English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
polymorphic equality and overloading
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-07-01 (08:39)
From: Brian Rogoff <bpr@b...>
Subject: Re: polymorphic equality and overloading
On Thu, 29 Jun 2000, Eijiro Sumii wrote:
> Dear Caml Developers/Users,
> (sorry that I don't know French)
> This might be an FAQ, but could someone please give a rationale to the
> polymorphic (in)equalities such as = and < in Caml?

(Note: I'm no type theorist, just a humble programmer)

Equality really is overloaded, but since overloading isn't easily
integrated into ML style type systems, some other solution is chosen. 
In SML, it is eqtypes, in OCaml, it is polymorphic (in)equality. 
People are working furiously on better solutions as we write. I 
read in the "ML-2000" design paper that eqtypes would go away in the 
next (standard) ML, so clearly not everyone is happy with the SML 
solution either.

> While they have a
> parametric polymorphic type 'a -> 'a -> bool, their semantics is ad
> hoc rather than parametric with respect to the type 'a (for example,
> they are undefined for functions),

Well, there is a little decidability problem for function equality... :-)

> which I found confusing to some
> users---at least, a friend of mine was confused, and chose Haskell
> (which has type classes) over Caml!

I agree that polymorphic equality is a hack, but I'd advise patience. 
It isn't clear that type classes are the best solution, and Jun Furuse 
and Pierre Weiss are working on adding some form of overloading to OCaml. 
There have been some threads on this topic in the Caml list. See 


-- Brian