What is this syntax `type t = (string,int,String.comparator_witness) Map.t`?

I am reading Real World Ocaml. I read about the modules and functors.

This part type t = (string,int,String.comparator_witness) Map.t of it is not making sense. What is it doing? What is this syntax? Any pointers in the docs?

open Base

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

let empty = Map.empty (module String)

let to_list t = Map.to_alist t

let touch t s =
  let count =
    match Map.find t s with
    | None -> 0
    | Some x -> x
  in
  Map.set t ~key:s ~data:(count + 1)

Source: http://dev.realworldocaml.org/files-modules-and-programs.html

Thank you!

I found this syntax also in use in this question. Destructive substitution: is it possible to replace a type constructor with a monomorphic type?

Hi,

this is just a type with multiple parameters :
https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora016.html

(search for type parameter)

1 Like