06 Module and Structure Syntax and Semantics

Let's look at the syntax and semantics of modules.

Syntax

module ModuleName = struct
    definitions
end

Module definitions must be capitalized. Idiomatically, module names are written in CamelCase, rather than snake_case. Definitions can be anything we've seen:

Semantics

To evaluate a structure, just evaluate each definition in order from the top to the bottom. The result is a module value (or simply module).

Module values are not like other values. They cannot be bound to a name with let, and they cannot be passed to functions or returned.