On 12/02/10 03:33, OGrandeDiEnne wrote: > How can i force the type of values in a map ? > > Suppose i want to create a map from string to int. > > module MyMapModule = Map.Make > (struct > type t = string (*keys of the map are identifiers*) > let compare = Pervasives.compare > end) > ;; > > the signature of MyMapModule.empty is a generic > > 'a MyMapModule.t = <abstr>
The problem is the same with any polymorphic type e.g. 'a list. You can create a .mli file that provides only what you want to expose. There's no magic but it works. foo.mli: type t val find : string -> t -> int val add : string -> int -> t -> t ... foo.ml: module M = Map.Make(String) type t = int M.t let find = M.find let add = M.add ... Martin -- You received this message because you are subscribed to the Google Groups "ocaml-developer" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/ocaml-developer?hl=en For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html
