2
votes

I was looking over the map.ml file to see what it consists of and I came across a signature which I don't understand. Its the S signature.

module type S =
  sig
    type key
    ...
    val mapi: (key -> 'a -> 'b) -> 'a t -> 'b t
  end

I understand how the signature OrderedType and the functor Make are used in conjunction to create modules but I'm at a loss figuring out how the S signature fits into the map module. Is the S signature just a generic signature for the created modules from Make?

1

1 Answers

3
votes

Yes, S is the of the output type of the Map.Make functor. In other words, when you apply Map.Make to an ordered type, you get a module of type S, where S.key is the ordered type. So, S is in essence the type of a map, except the key type needs to be filled in by applying Map.Make.