Documentation

ImportGraph.Shake.Workspace

WorkspaceModel and shake #

This file defines interactions between a WorkspaceModel and shake. The import hierarchy and workspace model data allows us to turn needs into imports and compare different imports with respect to minimality. Notably, it provides

Assuming that the indices in Needs correspond to module indices in the provided workspace model, record an Import for each set index in Needs in some order. This does not remove redundant imports. By default, this skips modules with prefix Init.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[inline]

    The index of Init.lean.

    Equations
    Instances For

      Every non-prelude file adds public import Init and public meta import Init to every file behind the scenes. This repesents (exactly) those two files. This should be added to any synthetic Needs to represent what a typical file actually gets. Returns ∅ if Init is not in the workspace model (this should be impossible).

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[inline]

        The transitive closure of the implicit Init imports added to every non-prelude file behind the scenes.

        Equations
        Instances For
          @[inline]

          The modules prior to the implicit Init imports added to every non-prelude file behind the scenes, but including the Init imports themselves. (Empty if Init cannot be found.)

          Equations
          Instances For

            Given a Needs, the IR which loading such a Needs would provide. Recall that IR is loaded transitively above any meta import, disregarding module system annotations, as well as non-transitively for any import all.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Convert extra mod uses into ImportNeeds.

              Unfortunately, ExtraModUse has no notion of allowMeta, so we make the unimposing choice to set allowMeta := true. Note that a conservative choice would insist on non-meta, but extra mod uses are frequently from metaprograms which are already meta (and thus records a non-meta extra mod use) or from e.g. lemmas used in tactic proofs (which allow meta). So we accept unlikely possible breakage to avoid suggesting e.g. meta import Foo; import Foo or missing out on viable declaration locations in #find_home.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Collapse the ImportNeeds of all declarations in DeclNeeds. This is incorrect for splitting up declarations, but adequate for moving them to a single place.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Computes a mapping LibIdx → Array ModIdx assigning to each library in the workspace model an array of modules which provide needs : ImportNeeds and are minimal. Namely, provider modules which are downstream of other provider modules (ignoring module system annotations) are knocked out.

                  It then ranks the "winning" modules first by import depth among imports from the same library (i.e. not counting imports of upstream libraries towards the depth), then by number of previous modules from the same library, then by absolute number of previous modules, then alphabetically.

                  league : ModuleBitset specifies the modules among which the competition is conducted. If none, this is all modules.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For