所以,当你定义模块的结构,它可以延长另一个模块关闭它:扩展递归模块
module Base = struct
type t = Name of string
end
module Child = struct
include Base
end
Child.Name "test"
(* - : Child.t = Child.Name "test" *)
然而,随着recursive modules using recursive signatures工作时,我遇到问题时,我尝试延长模块:
module rec Base : sig
type t = | Name of string
end = Base
and Child : sig
include Base
end = Child
当我这样做,我得到一个错误说:
Error: Unbound module type Base
在使用此递归模块技巧时,您不能扩展模块吗?我误会了什么或做错了什么?
我想补充一点,远离递归模块是个好主意。 –
@ÉtienneMillon怎么回事?你有什么文章可以把我和这件事联系起来吗? –
这被标记为实验性的,并且受到手册中的重大更改的影响,类型推断被降级,您不能将它们放在单独的文件中。我认为过去有健全的错误。打破递归或者在类型和值之间移动它几乎总是最好的解决方案。 –