Nested sub-modules within a module are delimited by matching ‘:- module’ and ‘:- end_module’ declarations. (Note that ‘:- end_module’ for nested sub-modules are mandatory, not optional, even if the nested sub-module is the last thing in the source file. Also note that the module name in a ‘:- module’ or ‘:- end_module’ declaration need not be fully-qualified.) The sequence of items thus delimited is known as a sub-module item sequence.
The interface and implementation parts of a nested sub-module may be specified in two different sub-module declarations. If a sub-module item sequence includes an interface section, then it is a declaration of that sub-module; if it includes an implementation section, then it is a definition of that sub-module; and if includes both, then it is both declaration and definition.
It is an error to declare a sub-module twice, or to define it twice. It is an error to define a sub-module without declaring it. As mentioned earlier, it is an error to define a sub-module in the interface section of its parent module.
If a sub-module is declared but not explicitly defined, then there is an implicit definition with an empty implementation section for that sub-module. This empty implementation section will result in an error if the interface section of a sub-module contains any of the following: