https://facebook.github.io/reason/modules.html#modules-basic-modules
I don’t see any import or require in my file; how does module resolution work?
Reason/OCaml doesn’t require you to write any import; modules being referred to in the file are automatically searched in the project. Specifically, a module Hello asks the compiler to look for the file hello.re or hello.ml (and their corresponding interface file, hello.rei or hello.mli, if available).
A module name is the file name, capitalized. It has to be unique per project; this abstracts away the file system and allows you to move files around without changing code.
我尝试了原因模块系统,但无法理解它是如何工作的。
open
1)和之间有什么区别include
?
2)我有foo.re
定义模块的文件Foo
。我有文件bar.re
并想从模块调用函数Foo
。
我应该open
还是include
模块Foo
?bar.re
或者只是直接访问 - Foo.someFunction
?
3)模块接口应该只实现y*.rei
文件吗?并且模块接口文件应该具有相同的名称但带有rei
ext?