From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 15487BB83 for ; Mon, 3 Jul 2006 17:10:29 +0200 (CEST) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.207]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k63FATcQ015468 for ; Mon, 3 Jul 2006 17:10:30 +0200 Received: by nz-out-0102.google.com with SMTP id m7so568186nzf for ; Mon, 03 Jul 2006 08:10:28 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rBx43KoWvXXNYRbo7xLzsZMFioN2wkjyQ3S/ntOb7mMYGmY/SojlXie0d7rHQVe9+rmuYPtkvYV5QuD9SwRn0bfI734Mp7C0MyXCMkkBQughpr5Gc1IzCcWj2ncODObNk6KqYxGehDljTFzx7Whroxtu5D4ZHkqKomRYT91RIQU= Received: by 10.36.139.3 with SMTP id m3mr3732763nzd; Mon, 03 Jul 2006 08:10:28 -0700 (PDT) Received: by 10.36.101.10 with HTTP; Mon, 3 Jul 2006 08:10:28 -0700 (PDT) Message-ID: Date: Tue, 4 Jul 2006 03:10:28 +1200 From: "Jonathan Roewen" To: "Bruno De Fraine" Subject: Re: [Caml-list] Type from local module would escape its scope? Cc: caml-list@yquem.inria.fr In-Reply-To: <5E0B2C43-5EDD-423F-B2ED-8BC025596DC7@vub.ac.be> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <069A1F65-E50C-4363-9CCA-C6CC9A453D09@vub.ac.be> <20060703155131.7031cffa@is003364.intra.cea.fr> <5E0B2C43-5EDD-423F-B2ED-8BC025596DC7@vub.ac.be> X-j-chkmail-Score: MSGID : 44A93365.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44A93365.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; iter:01 foo:01 endline:01 iter:01 stringset:01 struct:01 stringset:01 struct:01 caml-list:01 argument:01 hmm:02 string:02 string:02 scope:03 module:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE,RCVD_BY_IP autolearn=disabled version=3.0.3 > Thanks for your explanations! To get closer to the problem that > caused me to investigate the error: so there is no way to make f1 > into an argument in the following function iter_uniques (other than > as a method or record field)? > > let f1 add empty = List.fold_right add ["foo"; "bar"; "bar"] empty ;; > let f2 = print_endline ;; > > let iter_uniques comparison_fun = > let module StringSet = > Set.Make(struct > type t = string > let compare = comparison_fun > end) in StringSet.iter f2 (f1 StringSet.add StringSet.empty) > ;; Hmm, you could use a ref (which yes, is a record type). let dyn_comparer = ref compare let dyn_compare a b = !dyn_comparer a b module SS = Set.Make(struct type t = string let compare = dyn_compare end);; let iter_uniques f1 f2 = SS.iter f2 (f1 SS.add SS.empty);;