我有一个Mod受签名限制的模块Sig.该模块有一个Nested子模块.签名具有匹配的Nested子签名:
module type Sig = sig
val a : int
module type Nested = sig
val b : int
end
end
module Mod : Sig = struct
let a = 1
module Nested = struct
let b = 2
end
end
Run Code Online (Sandbox Code Playgroud)
但是,这会产生以下错误:
Error: Signature mismatch:
Modules do not match:
sig val a : int module Nested : sig val b : int end end
is not included in
Sig
The field `Nested' is required but not provided
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
在代码中声明嵌套模块的方法是错误的:
module type Sig = sig
val a : int
module Nested : sig val b : int end
end
module Mod : Sig = struct
let a = 1
module Nested = struct
let b = 2
end
end
Run Code Online (Sandbox Code Playgroud)
查看子模块如何在以下链接中声明:http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora131.html
它可以帮助我修复你的错误.