What happens if the caller writes
f 0 : int t option
? The caller has chosen'a = int
, but the function implementation mandates'a = string
. That’s why this definition is ill-typed.
While I agree with this, this is a type error even without abstract types. I guess the question here is what should the type argument to t
be, which is why the module method works (the type is Returned_module.t
). I didn’t consider this, which I guess is an answer to my question.
I thought about using a wrapper GADT as well, which is more elegant than the modules but still a bit less than I would like. Oh, well – it makes sense .
Thanks!