OCaml functors taking an OCaml functor as arguments, or returning OCaml functors are never mentioned in the manual .
Is there a technical reason that prevents OCaml to have higher-order modules?
Higher-order functors are supported and work as expected:
module type endo = sig
module type t
module F: t -> t
end
module Twice(F:endo) = struct
module type t = F.t
module F(X:t) = F.F(F.F(X))
end
The manual merely considers that it is a not surprising feature.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.