Given a type
type 'a ty
and a module type
module type TY = (sig type a val x : a ty end)
I can define
let toTY (type b) (x' : b ty) : (module TY) =
(module struct
type a = b
let x = x'
end)
and I would like to define a function (although this doesn't typecheck)
let ofTY (m : (module TY)) : m.a ty = ???
with the intended effect that whenever m : (module TY) then ofTY m : m.a ty, so
trying to define it as
let ofTY (type b) (m : (module TY with type a = b)) : b ty = ...
does not have the intended effect.
What is the appropriate way of defining ofTY?