I’m not sure if below is the minimal code example, but what I’m trying to accomplish is the function
k below, which takes a function and a first-class module, and the function is just a forwarding function for something in the first-class module. I want to give these forwarding functions a type but I don’t want to expose the
't type variable because it is not really necessary, I’m just trying to enforce the relationship in the forwarding function.
Is this possible?
The error is:
This expression has type (module FOO with type t = F.t) but an expression was expected of type (module FOO with type t = $V_'t) Type F.t = t is not compatible with type $V_'t
module type FOO = sig type t val get : unit -> t val bar : t -> string end module Fimpl : FOO = struct type t = int let get () = 4 let bar = string_of_int end type 'a f = V : ((module FOO with type t = 't) -> 't -> 'a) -> 'a f let bar (type t) (module F : FOO with type t = t) (t:t) = F.bar t let k (type t) (V f) (module F : FOO with type t = t) = let t = F.get () in f (module F) t let () = ignore (k (V bar) (module Fimpl))