Hi there, I found there are some references Module types / aliases, Type aliases for extensible types and Using module type of with module aliases in OCaml 4.07.* discussed before, but seems not suits for me.
I am writing a project with multiple modules, let’s say
Temp I declared as below
(* temp.ml *) open core type t = int[@@deriving sexp, compare, hash] include Comparable.Make (Int)
Then I declared a set in module
(* a.ml *) module TempSet = Set.Make(Temp)
Now I want to use
TempSet module in
B as below
(* b.ml *) let foo (s : A.TempSet.t) = A.TempSet.iter s ~f:(fun x -> printf "%d " x)
However, now I get the compiler error in the lambda function as.
This expression has type A.TempSet.Elt.t but an expression was expected of type int
Since I generate
TempSet based on
TempSet.Elt.t should be
Temp.t , but why the type is inconsistent here?
Also, I found that if I write this function in module
A, the error changes to
This expression has type A.Temp.t but an expression was expected of type int
Though still not working, but it makes more sense. So I guess this is about module namespace or type alias, is there anything I am missing?