Module Map.M

M is meant to be used in combination with OCaml applicative functor types:

type string_to_int_map = int Map.M(String).t

which stands for:

type string_to_int_map = (String.t, int, String.comparator_witness) Map.t

The point is that int Map.M(String).t supports deriving, whereas the second syntax doesn't (because there is no such thing as, say, String.sexp_of_comparator_witness -- instead you would want to pass the comparator directly).

In addition, when using @@deriving, the requirements on the key module are only those needed to satisfy what you are trying to derive on the map itself. Say you write:

type t = int Map.M(X).t [@@deriving hash]

then this will be well typed exactly if X contains at least:

Parameters

Signature

type nonrec 'v t = (K.t'vK.comparator_witness) t