我想定义以下模块层次结构,但它不起作用:
module type A = sig
type t
end
module type B = sig
type u
include A
end
module type C = sig
(* Error: Unbound type constructor u *)
include B with type t = u list
end
为什么类型 u
出现错误?
最佳答案
=
之后的类型应该在您尝试包含/修改的模块外部可用。
在这里,你会这样做:
module type C = sig
type u
include B with type u := u and type t = u list
end
关于types - OCaml 中模块包含的类型约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28750001/