English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2004-03-23 (21:02)
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 :
    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

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.


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