caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Harrison <John.Harrison@cl.cam.ac.uk>
To: caml-list@pauillac.inria.fr
Cc: John.Harrison@cl.cam.ac.uk
Subject: Re: Polymorphic comparison
Date: Tue, 18 Oct 94 13:54:01 +0100	[thread overview]
Message-ID: <"swan.cl.cam.:256500:941018125425"@cl.cam.ac.uk> (raw)
In-Reply-To: Your message of "Tue, 18 Oct 94 11:40:09 BST." <9410181040.AA18410@lip.ens-lyon.fr>


Judicael Courant writes:

| I think this polymorphic comparison is quite easy to implement in the
| following way:
|
| #open "hashtbl";;
| let c x y = (hash x) <= (hash y);;
| #infix "c";;

I should have pointed out that I want a true ordering, i.e. something
antisymmetric. (Presumably the above isn't, since several different items might
yield the same hash value). The idea is to be able to sort a list of elements
of any type into an arbitrary but fixed order.

Pierre Weis adds:

| In the next 0.7 version of Caml Light, we plan to extend comparisons to a
| polymorphic function (i.e. prefix < : 'a -> 'a -> bool, instead of the
| now available prefix < : int -> int -> bool).

That would be all I want, I think.

| To extend comparisons to unrelated pairs of values, that is defining
| prefix <  with type scheme 'a -> 'b -> bool seems a bit strange to me.
| What do you plan to do with such a general type scheme for comparisons ?

I don't foresee any use for such a general mechanism, although that's how it
was in Classic ML.

The applications I have in mind are in theorem proving; for example
canonicalizing expression trees based on an associative-commutative operation.
However I can envisage some other uses, e.g. set/multiset comparison. I suspect
that if you can only do pairwise comparison this is O(n^2), whereas just
sorting both sets first then comparing should be O(n log n).

John.




  reply	other threads:[~1994-10-18 18:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-18 10:40 Judicael Courant
1994-10-18 12:54 ` John Harrison [this message]
1994-10-19  8:47   ` Xavier Leroy
  -- strict thread matches above, loose matches on Subject: below --
1994-10-18 12:46 Franck.Delaplace
1994-10-18  9:43 Pierre Weis
1994-10-18  9:32 Pierre Weis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='"swan.cl.cam.:256500:941018125425"@cl.cam.ac.uk' \
    --to=john.harrison@cl.cam.ac.uk \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).