Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Basic question about modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Kenneth Knowles <kknowles@b...>
Subject: Re: [Caml-list] Basic question about modules

> types and functions, I'm at a loss as how to write the contents
> of the mli file that corresponds to the one automatically generated
> above (specifically the StringMap bit).
> 
> A pointer would be much appreciated, either how to write the .mli
> file, or a generally better way of doing this stuff.

Well, you can use `ocamlc -i' to initially create the .mli file, or inspect its
output for help.  Also, by typing it into the ocaml toplevel you get:

# module StringMap = Map.Make(String);;
module StringMap :
  sig
    type key = String.t
    and 'a t = 'a Map.Make(String).t
    val empty : 'a t
    val add : key -> 'a -> 'a t -> 'a t
    val find : key -> 'a t -> 'a
    val remove : key -> 'a t -> 'a t
    val mem : key -> 'a t -> bool
    val iter : (key -> 'a -> unit) -> 'a t -> unit
    val map : ('a -> 'b) -> 'a t -> 'b t
    val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
    val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
  end

There is some syntax for "Map.S with type key = String.t" that would be a bit
prettier, but I don't remember it offhand.

Kenn

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners