caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jean-Christophe Filliâtre" <Jean-Christophe.Filliatre@lri.fr>
To: Fabrice Marchant <fabricemarchant@free.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Problem with module inclusion
Date: Thu, 05 Jun 2008 09:36:09 +0200	[thread overview]
Message-ID: <48479769.80609@lri.fr> (raw)
In-Reply-To: <20080604141959.6e095093@free.fr>

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


  reply	other threads:[~2008-06-05  7:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-04 12:19 Fabrice Marchant
2008-06-05  7:36 ` Jean-Christophe Filliâtre [this message]
2008-06-05 18:10   ` [Caml-list] " Fabrice Marchant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48479769.80609@lri.fr \
    --to=jean-christophe.filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=fabricemarchant@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).