Browse thread
[Caml-list] User-defined equality on types?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Brian Rogoff <bpr@b...> |
| Subject: | Re: [Caml-list] User-defined equality on types? |
On Mon, 23 Apr 2001, Xavier Leroy wrote: > > I'd like to suggest allowing the user to define a chosen interpretation > > of the equality symbol, and perhaps the polymorphic orderings too, on > > each new (maybe just abstract) data type. This seems natural in the > > context of abstract data types with non-canonical representation, giving > > a kind of quotient type. Has this ever been considered? > > Yes. This was one of the first motivations for Haskell type classes, > I believe. Would the proposed generic polymorphism extension solve this problem? It seems that it would, and it would be a clean solution. John, in case you haven't seen it it is a typeclass like approach where instead of defining a type class you define generic functions which have a typecase and dispatch to the right function (like CLOS). > > Are there good reasons against it? > > It's not easy to implement. One can do it the Haskell way, by passing > around compiler-generated functions as extra arguments, but the > language extensions needed to declare ad-hoc polymorphic operations > and define implementations for these operations at particular types > are fairly complex. I'd rather not add Haskell's type classes to > OCaml :-) That's too bad. I was hoping that one day the nice features of Haskell would get stol^H^H^H^Hused in some future ML and I've always envied Haskeller's their type classes. -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr