这个 OCaml 代码的语法规则是什么?

What is the grammar rule for this OCaml code?

我对OCaml不是很熟悉,不过最近一直在分析OCaml的语法。我遇到了这个 include 结构,我看不到它与哪个语法规则相关:

include Warning(Loc).S

include 的语法规则定义为

include module-expr

moduule-expr 不允许在括号后加点。我怀疑这是一个扩展。有人可以指出这包括什么意思以及它与哪条规则有关吗?

语法指的是包含在

处找到的签名 S
module SpecificWarning = Warning (Loc)
include SpecificWarning.S

在这种情况下,语法允许匿名构造 SpecificWarning

include (Warning(Loc)).S

句法规则链接在 the rule for module-type seeing that it allows for valid modtype-path segments 下,它允许 extended-module-names(例如,模块名称可能由括号函子应用程序语法扩充)后跟 .,然后是标识符作为通过仿函数应用程序创建的匿名模块中的 modtype-name

您指的是确实不允许的模块。但是这个例子是关于签名的,也就是模块类型。这是激励性的演示:

       OCaml version 4.01.0

# module type S = sig type t end;;
module type S = sig type t end
# module Make(T : S) = struct
  module type S = sig
      type t = T.t list
    end 
end;;
        module Make :
  functor (T : S) -> sig module type S = sig type t = T.t list end end
# module type Example = sig
            include Make(String).S
          end;;
    module type Example = sig type t = String.t list end
#