types - OCaml 中模块包含的类型约束

标签 types module include ocaml

我想定义以下模块层次结构,但它不起作用:

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/

相关文章:

scala - 在没有隐式证据对象的情况下直接使用 Scala 类型类

typescript - 在 TypeScript 接口(interface)中描述属性对象

module - Pycharm os.get_terminal_size() 不工作

c++ - VC9 C1083 无法打开包含文件 : 'boost...' after trying to abstract an include dependency

PHP Include 不显示页眉和页脚

sql-server - 在 Sql Server 中存储 UInt32 的最佳方法

r - 如何在 R 中使用 igraph 删除小社区?

javascript - 为什么 2 个不同的模块在添加为依赖于第三个模块时可以相互访问?

PHP:包含函数不起作用

c++ - long double C++的范围是多少