module type MTYPE’ = functor (P:PTYPE) → MTYPE
…
MTYPE’ with type input = a and type output = b
That won’t quite work. The existential is nested underneath the parameter (i.e. that functor type lets the functor choose different input and output for different P). Instead you want to move the existential outside of the functor:
module type MTYPE' = sig
type a
type b
module F : functor (P : PTYPE) -> MTYPE with type input = a type output = b
end
...
MTYPE' with type a = a and type b = b