简体   繁体   English

OCaml 中的高阶模块

[英]higher order modules in OCaml

OCaml functors taking an OCaml functor as arguments, or returning OCaml functors are never mentioned in the manual . OCaml 仿函数将 OCaml 仿函数作为 arguments 或返回 OCaml 仿函数在手册中从未提及。

Is there a technical reason that prevents OCaml to have higher-order modules?是否存在阻止 OCaml 拥有高阶模块的技术原因?

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.该手册仅认为这是一个不足为奇的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM