From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 573A5BB91 for ; Wed, 26 Jan 2005 09:25:58 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0Q8Pvmp024880 for ; Wed, 26 Jan 2005 09:25:58 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA26178 for ; Wed, 26 Jan 2005 09:25:57 +0100 (MET) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0Q8Pvhg028264 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 26 Jan 2005 09:25:57 +0100 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 0C35919E70C; Wed, 26 Jan 2005 09:25:57 +0100 (CET) Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05362-04; Wed, 26 Jan 2005 09:25:56 +0100 (CET) Received: from smtp.lri.fr (serveur3-5 [129.175.3.5]) by ext.lri.fr (Postfix) with ESMTP id ED41219E6F2; Wed, 26 Jan 2005 09:25:56 +0100 (CET) Received: from pc8-142 (pc8-142 [129.175.8.142]) by smtp.lri.fr (Postfix) with ESMTP id 2A4BDCED99; Wed, 26 Jan 2005 09:25:55 +0100 (CET) Received: from filliatr by pc8-142 with local (Exim 3.36 #1 (Debian)) id 1CtiUu-0008UP-00; Wed, 26 Jan 2005 09:25:56 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16887.21524.707176.646417@gargle.gargle.HOWL> Date: Wed, 26 Jan 2005 09:25:56 +0100 To: Mike Hamburg Cc: caml-list@inria.fr Subject: Re: [Caml-list] 'a Set? In-Reply-To: <727068A7-6F2C-11D9-8411-0003939A19AA@fas.harvard.edu> References: <727068A7-6F2C-11D9-8411-0003939A19AA@fas.harvard.edu> X-Mailer: VM 7.18 under Emacs 21.3.1 From: Jean-Christophe Filliatre X-Virus-Scanned: by amavisd-new at lri.fr X-Miltered: at concorde with ID 41F75415.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41F75415.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 filliatre:01 filliatre:01 lri:01 pervasives:01 functor:01 sig:01 val:01 sig:01 elt:01 ord:01 elt:01 ord:01 pervasives:01 functor:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: 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: module type OrderedType = sig type 'a t val compare: 'a t -> 'a t -> int end module type S = sig type 'a elt type 'a t ... end module Make(Ord: OrderedType): (S with type 'a elt = 'a Ord.t) or directly substitute Pervasives.compare for the comparison function to get a polymorphic data structure (and no functor anymore): module AlphaSet : sig type 'a elt type 'a t ... end Best regards, -- Jean-Christophe