I am a bit stuck.
If I declare these toy modules and functors:
module type Empty = sig end module type Type = sig type t end module F(E:Empty): Type with type t = int = struct type t = int end let f (module E:Empty) = (module F(E): Type with type t = int) let empty: (module Empty) = (module struct end)
I would like to define a first-class module of type Type from the function f without the type constraint. That is, something of this kind :
let forget: (module Type) = f empty
But this does not compile : the compiler complains that :
This expression has type (module Type with type t = int)
but an expression was expected of type (module Type)
For the record, this is perfectly fine:
let forget: (module Type with type t = int) = f empty
I am surprised of this behaviour, for the standard modules forgetting some type information is generally not a problem (that’s the basis for type abstraction, right ?). Why does it do that and how can I achieve what I want to do ?
Thanks all in advance