The syntax of a compound-unit/sig expression is:
(compound-unit/sig
(import import-element
)
(link (id : signature (expr unit-path
))
)
(export export-element
))
The import-elements of the import clause must all use the form (id : signature). The link clause is similar to the link clause of a compound-unit expression, but with two differences: an export signature must be present for each sub-unit and the import specifications unit-path have a different form. The export clause is also similar to the export clause of a compound-unit, but the export specifications export-element have a different form.
When a compound-unit/sig expression is evaluated, the result of each expr in the link clause is checked to insure that it is a signed unit and that the unit's export signature conservatively matches the corresponding signature. Also, the unit's import signatures must exactly match the signatures from the corresponding unit-paths (in the same order).
Each unit-path has one of the following forms:
simple-unit-path
(simple-unit-path : signature)
where a simple-unit-path is one of:
id
(id
)
In a simple-unit-path, the first id must be a unit identifier bound by another link sub-clause or the import clause. An (id id) form specifies a unit with the first id and the identifier of a sub-unit with the second id. Longer paths specify units with more nesting. (Units cannot be specified using id: prefixes.)
A unit-path with a signature uses the unit specified by the simple-unit-path, but restricts the names imported from the unit to those specified by the signature. (This signature must conservatively the signature at the unit id's binding.)
In the export clause, each export-element
has one of the following forms:
(var var-path)
(var var-path id)
(open unit-path)
(unit unit-path)
(unit unit-path id)
The export clause implcitly defines an export signature for the signed compound unit. The order the exported identifiers in this signature matches the order of the export-element sub-clauses.