OCaml:全局模块绑定
我正在从事一个OCaml:全局模块绑定,ocaml,Ocaml,我正在从事一个OCaml项目,我想为外部模块声明一些全局绑定。例如: module Test = struct open Another_module let module AM = Another_module let func1 a = AM.process a let func2 a = AM.process a end 然而,当我编译一些如上所述组织的代码时,我总是得到一个全局模块绑定语句的编译错误 Parse error: "in"
OCaml
项目,我想为外部模块声明一些全局绑定。例如:
module Test = struct
open Another_module
let module AM = Another_module
let func1 a =
AM.process a
let func2 a =
AM.process a
end
然而,当我编译一些如上所述组织的代码时,我总是得到一个全局模块绑定语句的编译错误
Parse error: "in" expected after [module_binding0] (in [str_item])
我做错什么了吗?谁能给我一些帮助吗?谢谢大家! 结构中模块定义的语法是 module Name = module-expression 所以你需要写作
module Test = struct
module AM = Another_module
let func1 a =
AM.process a
end
请注意,
module AM=other_module
不会使模块名AM
和other_module
完全可互换:它们在函子的参数中使用时并不等效,这是由于它们的方式。结构中模块定义的语法是
module Name = module-expression
所以你需要写作
module Test = struct
module AM = Another_module
let func1 a =
AM.process a
end
请注意,
module AM=othera_module
不会使模块名AM
和othera_module
完全可互换:它们在函子的参数中使用时是不等价的,这是因为这样。Thank you@Gilles.Thank you@Gilles。