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: Tim Docker <timothy.docker@m...>
Subject: [Caml-list] Basic question about modules
Having used haskell, I'm getting to grips with the core ocaml
language, but am somewhat confused by modules.

If I compile a simple file, X.ml:

 | module StringMap = Map.Make (String)
 | 
 | type info = int list StringMap.t
 |
 | type named_values = {
 |    details : info
 | }
 |
 | ..... other stuff ....

then ocamlc will automatically build a x.cmi file that exports
everything. I can use this from another file Y.ml:

 | let x = X.StringMap.empty;;
 |
 | let y = { X.details=X.StringMap.add "xxx" [1;2;3] x }

although the X.StringMap.fn syntax seems a bit unwieldy.

If I want to restrict what gets exported, I have to
write an x.mli file. Whilst I've written mli files for simple
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.

Thanks,

Tim