使用模块包含在OCaml中

Geo*_*off 6 ocaml types expression module

在OCaml 3.11中,我想使用include指令"扩展"现有模块,如下所示:

module MyString = struct
  include String
  let trim s = ...
end
Run Code Online (Sandbox Code Playgroud)

没问题.但现在我想明确地公开这个模块的类型(即在.mli文件中).我想要这样的东西:

module MyString : sig
  include String
  val trim : string -> string
end
Run Code Online (Sandbox Code Playgroud)

但是include语法不正确,因为String指的是模块,而不是模块类型(编译器确实是barf).我如何在这里引用String的模块类型(没有在sig表达式中明确地写出来)?

谢谢!

Pas*_*uoq 5

OCaml 3.12将有一个像module type of M我相信会解决你的问题的结构.同时,您可以让编译器生成冗长的签名ocamlc -i.对不起,但我认为这是你用3.11做的最好的.