From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 69505BB84 for ; Thu, 5 Jun 2008 09:36:10 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An4BAMczR0jAXQImiGdsb2JhbACSCAEBAQ8gnSs X-IronPort-AV: E=Sophos;i="4.27,593,1204498800"; d="scan'208";a="13258681" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 05 Jun 2008 09:36:10 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m557a5oU005458 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 5 Jun 2008 09:36:10 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmAAAAM0R0iBrw8Eo2dsb2JhbACSCAEBAQEBCAUIBxGdLg X-IronPort-AV: E=Sophos;i="4.27,593,1204498800"; d="scan'208";a="13520331" Received: from ext.lri.fr ([129.175.15.4]) by mail3-smtp-sop.national.inria.fr with ESMTP; 05 Jun 2008 09:36:09 +0200 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 6EAA8A4843; Thu, 5 Jun 2008 09:36:09 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lri.fr 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 tlGU7mEB6K84; Thu, 5 Jun 2008 09:36:09 +0200 (CEST) Received: from [192.168.0.10] (mry91-1-82-229-156-20.fbx.proxad.net [82.229.156.20]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ext.lri.fr (Postfix) with ESMTP id 25746A475D; Thu, 5 Jun 2008 09:36:09 +0200 (CEST) Message-ID: <48479769.80609@lri.fr> Date: Thu, 05 Jun 2008 09:36:09 +0200 From: =?ISO-8859-1?Q?Jean-Christophe_Filli=E2tre?= User-Agent: Thunderbird 1.5.0.14ubu (X11/20080306) MIME-Version: 1.0 To: Fabrice Marchant Cc: caml-list@inria.fr Subject: Re: [Caml-list] Problem with module inclusion References: <20080604141959.6e095093@free.fr> In-Reply-To: <20080604141959.6e095093@free.fr> X-Enigmail-Version: 0.94.2.0 OpenPGP: url=http://www.lri.fr/~filliatr/mykey.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 48479765.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 functor:01 orderedtype:01 sig:01 sig:01 val:01 val:01 bool:01 bool:01 struct:01 caml-list:01 int:01 int:01 Fabrice Marchant a écrit : > Here is a counter functor : *) > [...] > (* before Counters, that would be modified this way : > *) > module Counters ( X : Map.OrderedType ) : > sig > module XMap : > sig > type 'a t = 'a Map.Make(X).t > val empty : 'a t > val add : X.t -> 'a -> 'a t -> 'a t > val find : X.t -> 'a t -> 'a > val fold : (X.t -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b > val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool > end > type t = int XMap.t > val equal : t -> t -> bool > val zeroes : t > val incr : t -> X.t -> t > end > = > struct > module XMap = MapPlus ( Map.Make( X ) ) > > type t = int XMap.t > > let equal = XMap.equal ( = ) > > let zeroes = XMap.empty > > let incr map e = > (XMap.add e > (try succ (XMap.find e map) > with Not_found -> 1)) map > end > > (* unfortunately this doesn't work : how to access 'to_list' function through the Counters module ? With StringCounters.XMap.to_list ? > I'm confused. Should the Counters signature be modified ? You need - either to export to_list in signature of XMap above as val to_list : 'a t -> (X.t * 'a) list and then you'll be able to write StringCounters.XMap.to_list in your example - or to re-export it in module Counters, as let to_list = XMap.to_list and to declare it in signature of module Counters, as val to_list : t -> (X.t * int) list and then to use it as StringCounters.to_list in your example. Hope this helps, -- Jean-Christophe