From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 247B8BB81 for ; Sun, 12 Dec 2004 03:46:42 +0100 (CET) Received: from nexus.stwing.upenn.edu (NEXUS.STWING.UPENN.EDU [165.123.132.61]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBC2kekx014352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 12 Dec 2004 03:46:41 +0100 Received: from force.stwing.upenn.edu (force.stwing.upenn.edu [165.123.132.65]) by nexus.stwing.upenn.edu (8.12.10/8.12.9) with ESMTP id iBC2kcHA017763 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 11 Dec 2004 21:46:39 -0500 (EST) Received: from force.stwing.upenn.edu (localhost [127.0.0.1]) by force.stwing.upenn.edu (8.12.10/8.12.9) with ESMTP id iBC2kch4004485 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 11 Dec 2004 21:46:38 -0500 (EST) Received: (from wlovas@localhost) by force.stwing.upenn.edu (8.12.10/8.12.9/Submit) id iBC2kc2p004471 for caml-list@yquem.inria.fr; Sat, 11 Dec 2004 21:46:38 -0500 (EST) Date: Sat, 11 Dec 2004 21:46:37 -0500 From: William Lovas To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] How to use Set Datatype Message-ID: <20041212024637.GA11860@force.stwing.upenn.edu> Mail-Followup-To: caml-list@yquem.inria.fr References: <1102809942.2611.647.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1102809942.2611.647.camel@pelican.wigram> User-Agent: Mutt/1.5.4i X-Miltered: at concorde with ID 41BBB110.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; lovas:01 wlovas:01 stwing:01 upenn:01 caml-list:01 datatype:01 wrote:01 wrote:01 ocaml:01 implicitly:01 implicitly:01 o'caml:01 functor:01 struct: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: On Sun, Dec 12, 2004 at 11:05:42AM +1100, skaller wrote: > On Sun, 2004-12-12 at 08:12, Brian Hurt wrote: > > On Fri, 10 Dec 2004, Micha wrote: > > > Another thing- longtime Ocaml programmers tend to inline their structure > > definitions. > > Why? Because binding implicitly by name is basically bogus? What do you mean by bogus? And what do you mean by "binding implicitly by name"? I think experienced O'Caml programmers simply prefer to save the step of binding, especially if module you're passing as the argument to a functor is never used elsewhere. > So you write > > Set.Make(struct let compare=String.compare ... > > because the name in the functor 'compare' only agrees > accidentally. The anonymous struct there seems general, > and at least exposes explicitly the bindings. There's nothing "accidental" about it -- there is a very precise sense in which some modules are appropriate as input to the Set.Make functor, namely that they have the signature Set.OrderedType. This is just as precise as saying that 3 is appropriate as an argument to (+) while "hello" is not. O'Caml's module system is not some arbitrary hack -- it has a very rich and elegant type theoretic foundation. William