Reputation: 9110
I am working on a OCaml
project, and I would like to declare some global bindings for external modules. For example:
module Test = struct
open Another_module
let module AM = Another_module
let func1 a =
AM.process a
let func2 a =
AM.process a
end
However, when I compile some code organized as above, I always got a compile error for the global module binding sentence..
Parse error: "in" expected after [module_binding0] (in [str_item])
Am I doing anything wrong here? Could anyone give me some help? Thank you!
Upvotes: 0
Views: 115
Reputation: 107759
The syntax of a module definition inside a structure is
module Name = module-expression
The keyword sequence let module
is only used for a local binding of a module:
let module Name = module-expression in Name.x + Name.y
So you need to write
module Test = struct
module AM = Another_module
let func1 a =
AM.process a
end
Note that module AM = Another_module
does not make the module names AM
and Another_module
completely interchangeable: they aren't equivalent when used in the argument to a functor, due to the way .
Upvotes: 2