Ocaml: type export to mli file

I have a context.ml file where a map is defined

module CtxMap = Map.make(struct type t = int let compare = compare end) 

and map_get function with type CtxMap.key -> 'a CtxMap.t -> 'a

How to add CtxMap declaration to context.mli file? I cannot find a way to do this, since mli files cannot contain code.

+7
source share
2 answers
 module CtxMap : Map.S with type key = int 

In the map.ml file provided with map.ml , the signature name is for the functor S , and key is the only abstract type that you want to open to external modules.

+8
source

For reference, you can always:

 ocamlc -i -c context.ml 

to output the default .mli file to stdout. The only problem with this (in your case) is that it extends the signature of the card.

+6
source

All Articles