Algebra of an import hierarchy #
This file provides algebraic/compositional relationships between module system dependencies in an import hierarchy.
Notably, we provide transitive closure operators relative to an import hierarchy, which relies on the nontrivial composition of module system imports.
Future work #
- Document this more thoroughly.
- Consider making the
HierarchyAPI more featureful.
𝓘⟦n⟧ is the transitive closure of n with respect to the hierarchy 𝓘.
Instances For
Given an abstract NeedsKind [kImp⟩ and a collection of prearrows j [k⟩ · (Provides),
add to base the composed prearrows j [k⟩[imp⟩ · where composition is possible. Does not account
for public ⊆ private on the codomain side (see linearize).
Note that this does not add the original collection of prearrows to base.
Instances For
Instances For
Instances For
Given an abstract Import [kImp⟩ and a collection of prearrows j [k⟩ · (Provides), add
to base the composed prearrows j [k⟩[imp⟩ · where composition is possible.
Note that this does not add the original collection of prearrows to base.
Instances For
Given an abstract import [k⟩ and a collection of prearrows j [k⟩ · (Needs), forms
the composed prearrows j [k'⟩[k⟩ · where composition is possible.
Instances For
Instances For
Given an import hierarchy of arrows j' [_⟩ j and a preimport i [imp⟩ ·, forms the set of
prearrows obtained by transitively closing i [imp⟩ · with respect to the import hierarchy. This
is i [imp⟩ · together with compositions j [_⟩ i [imp⟩ ·. transDeps is assumed to be
reflexified.
Instances For
Instances For
Given an import hierarchy of arrows j' [_⟩ j and a preimport i [imp⟩ ·, forms the set of
prearrows obtained by transitively closing i [imp⟩ · with respect to the import hierarchy. This
is i [imp⟩ · together with compositions j [_⟩ i [imp⟩ ·. transDeps is assumed to be
reflexified.
Instances For
Instances For
Given a set of prearrows i [k⟩ · and an import hierarchy, includes in base the compositions
of arrows j [k'⟩ i [k⟩ · where composition is possible. Assumes every index is valid.
Instances For
Instances For
Instances For
Includes the public visibilities in the corresponding private visibilities, to represent a
"provides" relationship. A k : Needs is "linear" iff it accounts for public ⊆ private (and
likewise for both being meta). Accounting for this on the target side means that k.pub ⊆ k.priv
(public imports are available privately) and accounting for it on the source side means that
k.privOfPriv ⊆ k.priv (importing the private scope privately implies importing the public scope
privately).
Instances For
Whether public ⊆ private for the given Needs, on both the meta and non-meta levels.
Instances For
Removes private needs which can be inferred by accounting for public ⊆ private on both the
source and target side. See Needs.linearize for details.
Instances For
A Provides providing to a module the aspects of that module which it provides to itself. Note
that a module does not provide its own non-meta scopes as meta dependencies to itself.
Linearized.
Instances For
Adds in the reflexive availabilities of a given module, which are just the public and private
availabilities and not the meta lifted versions. This matches what is available within a given
module. Equivalent to a ∪ .reflOf i.
Note that this operation does not necessarily commute with transitive closure.
Instances For
Clears all dependencies at the given index.
Instances For
Checks if the Provides hierarchy transDeps provides arrows j [k⟩ i for all
(j [k⟩ ·) ∈ needs. Assumes transDeps is well-formed as a Provides hierarchy (i.e. linearized
and reflexified).
Instances For
Checks if the prearrows j [k⟩ · in n₁ are included in the arrows provided by the transitive
closure of n₂ with respect to the import hierarchy. Linearizes n₂ first, which ensures n₁ is
not penalized for itself being linearized and respecting public ⊆ private. Assumes transDeps
is a well-formed Provides hierarchy, i.e. linearized and reflexified.
Instances For
Returns an antilinearized reduced : Needs such that
a ≤ transDeps⟦reduced.linearize⟧
and reduced is minimal (perhaps non-uniquely) among such Needs.
The returned reduced is antilinearized, and thus suitable for converting to imports.
Does not assume a is linearized.
Instances For
Attempts to insert a among the set as of minimal elements as a new minimal element
according to lt. Clears elements of as that are above a, and ignores a if we already have
an element lower than a.
Instances For
At k, attempts to insert a among the set as of minimal elements as a new minimal element
according to lt. Clears elements of as that are above a, and ignores a if we already have
an element lower than a.
Instances For
The minimal values of xs under val according to lt, organized and compared per key
value. See minimalsPer for a version without val; val is essentially an optimization.
Instances For
The minimal elements of xs according to lt, organized and compared per key value.