From: "Frédéric Gava" <frederic.gava@wanadoo.fr>
Cc: <caml-list@inria.fr>
Subject: Re: [Caml-list] 'a Set?
Date: Wed, 26 Jan 2005 11:13:58 +0100 [thread overview]
Message-ID: <001401c5038f$c0ad0ba0$0100a8c0@mshome.net> (raw)
In-Reply-To: <16887.21524.707176.646417@gargle.gargle.HOWL>
Hi
> Mike Hamburg writes:
> > Is there any clean way to make a type 'a set, corresponding to Set.Make
> > of a module with type t='a and compare=Pervasives.compare? I'm trying
> > to make a module which uses sets of arbitrary types of objects, and I
> > don't want to have to make it a functor.
>
> This is a recurrent question on this list.
>
> > Is there a clean way to do this without removing the code from set.ml
> > and modifying it?
>
> Unfortunately, no.
> Note that when duplicating the code from set.ml, you can either keep a
> functorized code, with an additional type parameter:
I think this problem comes from the stdlib of OCaml. We have:
1) For the Hashtable
type ('a, 'b) t
and
val length : ('a, 'b) t -> int
and
module type S = sig
type key
type 'a t
.... end
2) For the Map
module type S = sig
type key
type +'a t
end
3) For the Set
module type S = sig
type elt
type t
val cardinal : t -> int
end
This is hard to understand why the signatures of those modules are so
differents. Why there is (for example) not for the set, this signature:
module type S = sig
type 'a elt
type 'a t
...
end ?
Furthermore there is no lenght/cardinal function for the Map. Note that
WeakHashtble have the function val count : t -> int, so three different
names for the same things. When I teach Ocaml, many students are lost with
this differences.
Best regards,
Frédéric Gava
next prev parent reply other threads:[~2005-01-26 10:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-25 23:54 Mike Hamburg
2005-01-26 8:25 ` [Caml-list] " Jean-Christophe Filliatre
2005-01-26 10:13 ` Frédéric Gava [this message]
2005-01-26 11:04 ` Radu Grigore
2005-01-26 12:04 ` Jacques Garrigue
2005-01-26 16:00 ` Alex Baretta
2005-01-26 16:14 ` Jacques Carette
2005-01-26 21:09 ` Mike Hamburg
2005-01-29 9:55 ` Radu Grigore
2005-01-26 9:13 ` Jon Harrop
2005-01-26 15:36 ` Frédéric Gava
2005-01-26 16:06 ` Jon Harrop
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='001401c5038f$c0ad0ba0$0100a8c0@mshome.net' \
--to=frederic.gava@wanadoo.fr \
--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).