Apologies if this has been covered elsewhere, because I couldn’t find it. I’m trying to understand, in detail, the conceptual differences between include
and open
. The docs are unclear.
Differences between include and open
Most of the time, you refer to values and types within a module by using the module name as an explicit qualifier. For example, you write List.map to refer to the map function in the List module. Sometimes, though, you want to be able to refer to the contents of a module without this explicit qualification. That’s what the open statement is for.
http://dev.realworldocaml.org/files-modules-and-programs.html#opening-modules
While opening a module affects the environment used to search for identifiers, including a module is a way of adding new identifiers to a module proper.
…
The difference between include and open is that we’ve done more than change how identifiers are searched for: we’ve changed what’s in the module.
http://dev.realworldocaml.org/files-modules-and-programs.html#including-modules
https://reasonml.github.io/en/try is handy for translating examples to Reason syntax.