unit-interface: {specification [;;
]} unit-implementation: {definition [;;
]}
Compilation units bridge the module system and the separate
compilation system. A compilation unit is composed of two parts: an
interface and an implementation. The interface contains a sequence of
specifications, just as the inside of a sig
...end
signature expression. The implementation contains a sequence of
definitions, just as the inside of a struct
...end
module
expression. A compilation unit also has a name unit-name, derived
from the names of the files containing the interface and the
implementation (see chapter 7 for more details). A
compilation unit behaves roughly as the module definition
module
unit-name:
sig
unit-interfaceend
=
struct
unit-implementationend
A compilation unit can refer to other compilation units by their names, as if they were regular modules. For instance, if U is a compilation unit that defines a type t, other compilation units can refer to that type under the name U.t; they can also refer to U as a whole structure. Except for names of other compilation units, a unit interface or unit implementation must not have any other free variables. In other terms, the type-checking and compilation of an interface or implementation proceeds in the initial environment
name1where name1...nameN are the names of the other compilation units available in the search path (see chapter 7 for more details) and interface1...interfacen are their respective interfaces.:
sig
interface1end
...namen:
sig
interfacenend