Thank you, I will try to understand.
Interestingly, the following compiles:
module type S = sig end
module SomeModule = struct end
module Functor (Arg : S) = struct
type t (* Note that [t] is abstract. *)
end
module Instance1 = Functor (SomeModule)
module Instance2 = Functor (SomeModule)
let foo : Instance1.t -> Instance2.t = fun x -> x
From the second linked thread:
So I think this is the minimal example of the issue I ran into:
module M = struct end
module Func (Arg : sig end) = struct
type t
end
module Intermediate = Func (M)
module M1 = Func (Intermediate)
module M2 = Func (Func (M))
let foo : M1.t -> M2.t = fun x -> x
This results in:
File "./nestedfunctor.ml", line 11, characters 34-35:
11 | let foo : M1.t -> M2.t = fun x -> x
^
Error: The value x has type M1.t = Func(Intermediate).t
but an expression was expected of type M2.t = Func(Func(M)).t
In my real-world use case, I think the problem is that when instantiating Set.Make, I need to make sure the exact same path is used. I think that will help me to avoid this problem in future.
Thank you so much!!