understanding module syntax defined at top of reasonml file

42 Views Asked by At

I am having difficulties finding an answer to the following syntax in reasonml

module A = B;

This is defined at the top of the .re file and I do not know where B is coming from.

EDIT:

When I try to log both A and B, with Js.log I get an error with the compiler saying a constructor cannot be found.

1

There are 1 best solutions below

0
On

This is a module alias. It binds the name of an existing module referred to by the name B to the name A.

B can refer to any module in scope, and modules can be brought into scope in several ways. A module alias such as this is one way. It could also be a local submodule or a submodule of another module that has been opened. But most modules in scope will typically be toplevel modules, which are created from every source file visible when compiling the current code unit/module. For example, a file named foo.re will create a module named Foo.

See the Reason documentation and OCaml documentation on modules for more details.