caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@jdh30.plus.com>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Core library (was: type var in functor instance?)
Date: Mon, 20 Sep 2004 21:17:42 +0100	[thread overview]
Message-ID: <200409202117.42329.jon@jdh30.plus.com> (raw)
In-Reply-To: <1095694982.2580.595.camel@pelican.wigram>

On Monday 20 September 2004 16:43, skaller wrote:
> > - to make an unfunctorized version of Set that uses Pervasives.compare,
> >   thus polymorphic
>
> This is already in the standard distro for Hashtbl.
> Why not for Set and Map as well? Why is this
> unsatisfactory?

You mean Hashtbl uses a polymorphic hash?

I think it would be productive to factor the tree out of set and map.

What if someone released backwards-compatible replacement modules for List, 
Array, Set, Map etc. which implemented this stuff? Then package maintainers 
could replace them if they liked the alternative implementations and coders 
could assume their existence. Maybe.

> I actually use heaps of Hashtbl of polymorphic kind
> and am ready to switch some over to an functor instance
> with key type int -- most of my tables use int keys
> and I hope to gain some performance and reasoning ability.

IMHO, hash tables are a bit less safe than sets and maps because hash tables 
make it easier to apply a structure-based polymorphic function incorrectly, 
e.g. to many abstract types, when a semantically meaningful (e.g. comparison) 
function should be used. For example, I don't think a hash table of sets 
would be very useful...

This strikes me as an important way to screw up ML programs and, consequently, 
it would be nice to address this. I've been trying to think of a solution but 
all I've come up with is: you could enforce the use of an appropriate 
comparison by making everything an object with its own compare method. But 
then you're going back to dynamic typing. Perhaps phantom types could do 
it...

Cheers,
Jon.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      parent reply	other threads:[~2004-09-20 20:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1095516867.2580.211.camel@pelican.wigram>
2004-09-20 11:58 ` [Caml-list] type var in functor instance? Jean-Christophe Filliatre
2004-09-20 15:43   ` skaller
2004-09-20 20:15     ` Daniel Bünzli
2004-09-20 20:17     ` Jon Harrop [this message]

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=200409202117.42329.jon@jdh30.plus.com \
    --to=jon@jdh30.plus.com \
    --cc=caml-list@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).