caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] User-defined equality on types?
@ 2001-04-19 21:00 Don Syme
  0 siblings, 0 replies; 8+ messages in thread
From: Don Syme @ 2001-04-19 21:00 UTC (permalink / raw)
  To: Alain Frisch, John R Harrison; +Cc: caml-list

> 
> On Wed, 18 Apr 2001, John R Harrison 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. 
> [snip]
> > Any opinions?
> 
> I support this suggestion. The standard equality/ordering/hashing
> functions are often adequate for most of the data structures, 
> and it would
> be useful to use them and just place a hook on specific types 
> to provide
> specialized implementation. It could almost be done with
> the "custom" block tag; the problem is that such blocks are 
> not garbage
> collected.  What about "custom Caml blocks" ?

I support the suggestion too.  In general I'm not a big fan of types
carrying much implicit functionality, but I like the "balance" that Caml
has struck by making hashing, equality, ordering and marshalling
available for all types.  And given that you can define these functions
for custom blocks, it cetainly makes sense to be able to define them for
types defined in Caml as well...

Cheers,
Don
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [Caml-list] User-defined equality on types?
@ 2001-04-18 19:42 John R Harrison
  2001-04-19 17:44 ` Francisco Valverde Albacete
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: John R Harrison @ 2001-04-18 19:42 UTC (permalink / raw)
  To: caml-list; +Cc: John Harrison


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? Are there good
reasons against it? Of course, I'd be happy for behaviour to be
undefined if the user nominates, say, a non-reflexive or non-substitutive
"equality" relation.

At present, I find that it's often quite inconvenient to use complicated
structures involving abstract types. In particular, I use the type of
arbitrary-precision numbers a lot, and frequently end up having to
define variants of standard polymorphic operations like set union for
several different types involving ":num". This would be avoided if I
could just automatically interpret "=" on the type ":num" as the special
comparison operator "=/".

Any opinions?
 
John.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-04-24  8:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-19 21:00 [Caml-list] User-defined equality on types? Don Syme
  -- strict thread matches above, loose matches on Subject: below --
2001-04-18 19:42 John R Harrison
2001-04-19 17:44 ` Francisco Valverde Albacete
2001-04-19 23:25   ` John R Harrison
2001-04-19 19:57 ` Alain Frisch
2001-04-23  8:54 ` Xavier Leroy
2001-04-23 16:42   ` Brian Rogoff
2001-04-24  8:33     ` Andreas Rossberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).