From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA13685; Mon, 28 May 2001 01:52:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA13656 for ; Mon, 28 May 2001 01:52:54 +0200 (MET DST) Received: from web11906.mail.yahoo.com (web11906.mail.yahoo.com [216.136.172.190]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id f4RNqrH12927 for ; Mon, 28 May 2001 01:52:53 +0200 (MET DST) Message-ID: <20010527235252.69384.qmail@web11906.mail.yahoo.com> Received: from [24.221.171.193] by web11906.mail.yahoo.com; Sun, 27 May 2001 16:52:52 PDT Date: Sun, 27 May 2001 16:52:52 -0700 (PDT) From: Tom _ Subject: Re: [Caml-list] classes vs modules To: caml-list@inria.fr Cc: Brian Rogoff In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > You can do this now if you make a PolySet module by > copying the > "monomorphic" implementation from the stdlib, > changing elt and t to > 'a elt and 'a t and, using that instead of Set, > something like: > > let f (cmp : 'a -> 'a -> bool) = > let module SomeSet = > PolySet.Make > (struct type 'a t = 'a let compare = > Pervasives.compare end) in > () Thanks; that's very useful to know, and it seems to be working. I think it might be useful to feature the ability to have polymorphic types in modules a little more prominently in the documentation. Maybe some of the standard modules could take advantage of this more (it would require some changes to their interfaces, I suppose). The type signatures I get out of my module after converting it are a little odd looking: type 'a t = 'a type 'a tree = Empty | Node of ... val insert : ('a t t t -> 'a t t -> bool) -> 'a t t t -> 'a t tree -> 'a tree ... Is there any useful information in the different number of t's? They should all be equivalent, right? BTW, I opted for just passing the "lt" function as explicit arguments to all the functions in the module that need them. That seems like the most general approach, although it means some extra arguments and it doesn't guarantee consistency, as people might pass incompatible versions of "lt" to different calls; a more convenient interface can then be wrapped around that, maybe in a different module Cheers, Tom. __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr