我正在将Tiger book中的 SML 入门代码转换为 OCaml。
让我感到困惑的是,在签名文件table.sig
(如下)中,没有提及IntMapTable
,但函子可以在另一个文件中访问而没有任何限制。
(* table.sig *)
signature TABLE =
sig
...
end
(* table.sml *)
functor IntMapTable (...) : TABLE =
struct
...
end
(* symbol.sml *)
...
structure Table = IntMapTable(...)
...
我的理解是,只有文件中的代码.sig
可以访问外部模块,而不是文件中的代码.sml
。不是这样吗?
此外,OCaml 中的等效代码可能是什么样的?这很尴尬,因为 functorIntMapTable
的结果类型是Table
,它是文件的封闭模块。