Additional OCaml Theory
This is some information that I think is not in the official OCaml manual.
Nor is it easily deduced therefrom.
I think that such information is vital to understanding the language and is available only haphazardly in the OCaml literature, and perhaps not even there.
Scope of type constructors and parameters
Somewhere around here:
A typeconstr-name within a typedef within a type-definition within a struct … end construct within a module-expr is a new type constructor name whose scope is the following definitions and exprs of the struct … end.
[One of the two following texts:]
- Any type parameters (type-params) within that typedef must be distinct and their scope is the type-information of that typedef.
- A type parameter (type-param) is within a typedef.
It must occur just once within the type-params of that typedef and may occur 0 or more times in the type-information of that typedef.
A sequence of specifications may appear in
Each typedef of a type-definition among the specifications of such a sequence introduces a new type constructor name whose scope is:
- the type-informations of the typedefs of the type-definition,
- and also the following specifications of the sequence.
I would be relieved if the word ‘Only’ were inserted before the sentence beginning: “These type parameters can appear” in section 6.8.1.
For a module to match a module signature, the typeconstr-name of each tyedef of the signature, most appear as a typeconstr-name of some tyedef of the module.
Info from there needs sharpening and inclusion here.
This is alternate terminology.