package merlin-lib
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=49b3b4c778c12125fc7405e73790b0b312d5d79749dd73d4838b6562a2533022
sha512=6350ff076ac61727c48bc098a05520c5d343f3323b2f3b6d7d69fdd568e51abca6945cbcbc3a6ae97fd198bd7bbdcae823fbd0f3f14a37972fe713da2ed14f2d
doc/merlin-lib.ocaml_typing/Ocaml_typing/Subst/index.html
Module Ocaml_typing.Subst
Source
Substitutions
Substitutions are used to translate a type from one context to another. This requires substituting paths for identifiers, and possibly also lowering the level of non-generic variables so that they are inferior to the maximum level of the new context.
Substitutions can also be used to create a "clean" copy of a type. Indeed, non-variable node of a type are duplicated, with their levels set to generic level. That way, the resulting type is well-formed (decreasing levels), even if the original one was not.
In the presence of local substitutions for module types, a substitution for a type expression may fail to produce a well-formed type. In order to confine this issue to local substitutions, the type of substitutions is split into a safe and unsafe variant. Only unsafe substitutions may expand a module type path into a generic module type.
Type familly for substitutions
When applied to a signature item, a substitution not only modifies the types present in its declaration, but also refreshes the identifier of the item. Effectively this creates new declarations, and so one should decide what the scope of this new declaration should be.
This is decided by the scoping
argument passed to the following functions.
val modtype_declaration :
scoping ->
t ->
Types.modtype_declaration ->
Types.modtype_declaration
Composition of substitutions: apply (compose s1 s2) x = apply s2 (apply s1 x) *