From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 33E74BB91 for ; Wed, 26 Jan 2005 11:12:14 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0QACDgA010425 for ; Wed, 26 Jan 2005 11:12:13 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA30623 for ; Wed, 26 Jan 2005 11:12:13 +0100 (MET) Received: from smtp1.wanadoo.fr (smtp1.wanadoo.fr [193.252.22.30]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0QACDVN007958 for ; Wed, 26 Jan 2005 11:12:13 +0100 Received: from me-wanadoo.net (x9.sequst.com [127.0.0.1]) by mwinf0108.wanadoo.fr (SMTP Server) with ESMTP id 24FE81C00D0A for ; Wed, 26 Jan 2005 11:12:13 +0100 (CET) Received: from nono (ARouen-106-1-40-157.w80-13.abo.wanadoo.fr [80.13.225.157]) by mwinf0108.wanadoo.fr (SMTP Server) with SMTP id C1D841C00CE7 for ; Wed, 26 Jan 2005 11:12:12 +0100 (CET) X-ME-UUID: 20050126101212794.C1D841C00CE7@mwinf0108.wanadoo.fr Message-ID: <001401c5038f$c0ad0ba0$0100a8c0@mshome.net> From: =?iso-8859-1?Q?Fr=E9d=E9ric_Gava?= Cc: References: <727068A7-6F2C-11D9-8411-0003939A19AA@fas.harvard.edu> <16887.21524.707176.646417@gargle.gargle.HOWL> Subject: Re: [Caml-list] 'a Set? Date: Wed, 26 Jan 2005 11:13:58 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Miltered: at nez-perce with ID 41F76CFD.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41F76CFD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; gava:01 gava:01 caml-list:01 pervasives:01 functor:01 stdlib:01 ocaml:01 hashtable:01 val:01 sig:01 sig:01 elt:01 val:01 elt:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: 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