Documentation

ImportGraph.Shake.Basic

Utilities for Shake types #

This file provides basic API for Needs, NeedsKind, and Bitset.

Counts the number of set bits in the binary representation of n.

Instances For
    @[inline]

    The number of set bits in a Bitset.

    Instances For
      @[inline]

      Whether the Bitset contains any elements.

      Instances For
        @[inline]

        The minimum size of the ambient index set necessary to hold Bitset.

        Instances For
          @[inline]

          The full set {0, ..., n - 1}.

          Instances For
            @[inline]

            The set s without the element i.

            Instances For
              @[inline]

              The highest set bit of a Bitset, if there is one.

              Instances For
                @[inline]

                The lowest set bit of a Bitset, if there is one.

                Instances For
                  @[inline]

                  a.le b iff every bit set in a is also set in b.

                  Instances For
                    @[inline]

                    a.le b iff every bit set in a is also set in b, and b is not equal to a.

                    Instances For
                      @[specialize #[]]
                      def ImportGraph.Shake.Bitset.foldr {α : Type} (s : Bitset) (init : α) (f : α → Nat → α) :
                      α

                      Fold over the set bit indices in a Bitset from high to low. This is more efficient for large bitsets than Bitset.foldl.

                      Instances For
                        @[specialize #[]]
                        def ImportGraph.Shake.Bitset.foldl {α : Type} (s : Bitset) (init : α) (f : α → Nat → α) :
                        α

                        Fold over the set bit indices in a Bitset from low to high. This is less efficient for large bitsets than Bitset.foldr.

                        Instances For

                          Array #

                          @[inline]

                          Regarding idxs : Array Nat as a set of Bitset indices, create a bitset which contains each idx ∈ idxs.

                          Instances For
                            @[inline]

                            The set bit indices of a Bitset in order from low to high.

                            Instances For
                              @[inline]

                              The set bit indices of a Bitset in order from high to low.

                              Instances For

                                ForIn #

                                @[specialize #[]]
                                def ImportGraph.Shake.Bitset.forInRev {m : Type → Type u_1} [Monad m] {β : Type} (s : Bitset) (init : β) (f : Nat → β → m (ForInStep β)) :
                                m (ForInStep β)

                                Iterates through the set bit indices of a Bitset from high to low.

                                Instances For

                                  A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset for large bitsets.

                                  Instances For
                                    @[inline]

                                    A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset for large bitsets.

                                    Instances For
                                      @[specialize #[]]
                                      def ImportGraph.Shake.Bitset.forIn {m : Type → Type u_1} [Monad m] {β : Type} (s : Bitset) (init : β) (f : Nat → β → m (ForInStep β)) :
                                      m (ForInStep β)
                                      Instances For

                                        A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. Bitset.HighToLow (Bitset.highToLow) is more efficient for large Bitsets.

                                        Instances For
                                          @[inline]

                                          A Bitset with a ForIn instance that traverses the bitset's indices from the highest index to the lowest. Bitset.HighToLow (Bitset.highToLow) is more efficient for large Bitsets.

                                          Instances For
                                            @[specialize #[]]

                                            Whether f returns true for all elements of the Bitset.

                                            Instances For
                                              @[specialize #[]]

                                              Whether f returns true for any elements of the Bitset.

                                              Instances For

                                                Extract the elements of a : Array α occurring at the indices specified in b : Bitset. Ignores elements of b that index outside the array.

                                                Instances For

                                                  Representations #

                                                  Converts a Bitset to a string of the form "◻◼◻◻◻◼◻◼◼◻◻◼", where indices run left-to-right from 0 and ◻ represents absence at that index, while ◼ represents presence.

                                                  By default, this shows only as many squares as necessary (or "◻" for an empty bitset), and so in the nonempty case the last square will always be ◼. Instead, univSize? : Option Nat can be provided to set the total number of indices, and will either truncate (even if higher bits are set) or pad with ◻ as appropriate.

                                                  Instances For

                                                    ForIn #

                                                    @[specialize #[]]
                                                    def ImportGraph.Shake.Needs.forInRev {m : Type → Type u_1} [Monad m] {β : Type} (n : Needs) (init : β) (f : NeedsKind × Nat → β → m (ForInStep β)) :
                                                    m (ForInStep β)

                                                    Iterates through NeedsKinds.all, and for each NeedsKind, iterates through the set bit indices of the corresponding Bitset from highest to lowest.

                                                    Instances For

                                                      A Needs with a ForIn instance that traverses the component bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset. Does not actually reverse the indices in the bitsets.

                                                      Instances For

                                                        A Needs with a ForIn instance that traverses the component bitset's indices from the highest index to the lowest. This is the most efficient traversal of a bitset. Does not actually reverse the indices in the bitsets.

                                                        Instances For
                                                          @[specialize #[]]
                                                          def ImportGraph.Shake.Needs.forIn {m : Type → Type u_1} [Monad m] {β : Type} (n : Needs) (init : β) (f : NeedsKind × Nat → β → m (ForInStep β)) :
                                                          m (ForInStep β)

                                                          Iterates through NeedsKinds.all, and for each NeedsKind, iterates through the set bit indices of the corresponding Bitset from lowest to highest.

                                                          Instances For

                                                            A Needs with a ForIn instance that traverses the component bitset's indices from the lowest index to the highest. b.highToLow is more efficient.

                                                            Instances For

                                                              A Needs with a ForIn instance that traverses the component bitset's indices from the lowest index to the highest. b.highToLow is more efficient.

                                                              Instances For

                                                                Operations #

                                                                @[instance_reducible]

                                                                Includes i in the field of Needs corresponding to k.

                                                                Instances For
                                                                  @[inline]
                                                                  def ImportGraph.Shake.Needs.applyAt {β : Sort u_1} (n : Needs) (k : NeedsKind) (f : Bitset → β) :
                                                                  β

                                                                  Apply f to the component bitset of n : Needs at the given NeedsKind. Rephrasing of f (n.get k) for readability.

                                                                  Instances For
                                                                    @[inline]

                                                                    Whether f : Bitset → Bool is true for any of the component bitsets of the given Needs.

                                                                    Instances For
                                                                      @[inline]

                                                                      Whether f : NeedsKind → Bitset → Bool is true for any of the component bitsets of the given Needs at the bitset's corresponding NeedsKind.

                                                                      Instances For
                                                                        @[inline]

                                                                        Whether f : Bitset → Bool is true for all of the component bitsets of the given Needs.

                                                                        Instances For
                                                                          @[inline]

                                                                          Whether f : NeedsKind → Bitset → Bool is true for any of the component bitsets of the given Needs at the bitset's corresponding NeedsKind.

                                                                          Instances For
                                                                            @[inline]
                                                                            def ImportGraph.Shake.Needs.fold {α : Type u_1} (n : Needs) (f : α → Bitset → α) (init : α) :
                                                                            α

                                                                            Folds f over the bitsets in Needs (in the order of NeedsKind.all).

                                                                            Instances For
                                                                              @[inline]
                                                                              def ImportGraph.Shake.Needs.foldWithKind {α : Type u_1} (n : Needs) (f : α → NeedsKind → Bitset → α) (init : α) :
                                                                              α

                                                                              Folds f over the bitsets in Needs at their corresponding NeedsKinds (in the order of NeedsKind.all).

                                                                              Instances For
                                                                                @[specialize #[1]]

                                                                                Applies f to all component Bitsets of the given Needs.

                                                                                Instances For
                                                                                  @[specialize #[1]]

                                                                                  Applies f to all component Bitsets of the given Needs at their corresponding NeedsKinds.

                                                                                  Instances For
                                                                                    @[specialize #[2]]

                                                                                    Applies f "pointwise" to the pairs of bitsets at each given NeedsKind. f (n₁.get k) (n₂.get k) = (n₁.map₂ n₂ f).get k for all k : NeedsKind.

                                                                                    Instances For
                                                                                      @[specialize #[2]]

                                                                                      Applies f "pointwise" to the pairs of bitsets at each given NeedsKind. f k (n₁.get k) (n₂.get k) = (n₁.mapWithKind₂ n₂ f).get k for all k : NeedsKind.

                                                                                      Instances For
                                                                                        @[inline]

                                                                                        Whether all component bitsets are empty.

                                                                                        Instances For
                                                                                          @[inline]

                                                                                          Whether the component bitset at k : NeedsKind is empty.

                                                                                          Instances For
                                                                                            @[inline]

                                                                                            The minimum size of the ambient index set necessary to hold every component Bitset.

                                                                                            Instances For
                                                                                              @[instance_reducible]
                                                                                              @[inline]

                                                                                              Whether each field of the first Needs is contained within the corresponding field of the second. Use with caution: this does not necessarily indicate that one Needs subsumes another. See also Needs.coveredBy for testing against an import hierarchy.

                                                                                              Instances For

                                                                                                Representations #

                                                                                                A braille cell depicting the set of NeedsKinds of n at index i. The left column holds non-meta needs, and the right column meta needs; the top row holds public needs, the middle row private, and the bottom row private-of-private.

                                                                                                Instances For
                                                                                                  @[inline]

                                                                                                  A braille cell in brackets depicting the set of NeedsKinds of n at index i. The left column holds non-meta needs, and the right column meta needs; the top row holds public needs, the middle row private, and the bottom row private-of-private.

                                                                                                  For the braille cell character without brackets, see Needs.brailleCellAt.

                                                                                                  Instances For
                                                                                                    def ImportGraph.Shake.Needs.toString (n : Needs) (univSize? : Option Nat := none) (dividers : Bool := true) :

                                                                                                    Represents a Needs as a string of the form e.g. │⠇│⠑│⠁│⠝│, where each braille cell represents the set of NeedsKinds expressed by a single "column" of the Needs (i.e. at a given index). The left column of each Braille cell are non-meta needs, and the right column holds meta needs; the top row holds public needs, the middle private, and the bottom private-of-private.

                                                                                                    By default, shows dividers (│) between each braille cell; dividers := false omits dividers.

                                                                                                    By default this shows only as many cells as necessary, or a single empty cell for an empty Needs. Instead, univSize? : Option Nat can be provided to set the total number of indices, and will either truncate (even if higher indices are set) or pad with empty cells as appropriate.

                                                                                                    Instances For
                                                                                                      @[inline]

                                                                                                      The NeedsKinds which land (directly) in the private scope.

                                                                                                      Instances For
                                                                                                        @[inline]

                                                                                                        The NeedsKinds which land (directly) in the public scope.

                                                                                                        Instances For
                                                                                                          @[inline]

                                                                                                          The NeedsKinds which (directly) demand the private scope.

                                                                                                          Instances For
                                                                                                            @[inline]

                                                                                                            The NeedsKinds which (directly) demand the public scope.

                                                                                                            Instances For
                                                                                                              @[inline]

                                                                                                              The NeedsKinds which land (directly) in the given scope.

                                                                                                              Instances For
                                                                                                                @[inline]

                                                                                                                The NeedsKinds which (directly) demand the given scope.

                                                                                                                Instances For
                                                                                                                  @[inline]

                                                                                                                  The NeedsKinds which land in the private scope after taking into account public ⊆ private on both ends. This is simply NeedsKind.all, but can help record why we're using it.

                                                                                                                  Instances For
                                                                                                                    @[inline]

                                                                                                                    The NeedsKinds which land in the public scope after taking into account public ⊆ private on both ends. This is simply toPublic, but can help record why we're using it.

                                                                                                                    Instances For
                                                                                                                      @[inline]

                                                                                                                      The NeedsKinds which demand the private scope after taking into account public ⊆ private on both ends.

                                                                                                                      Instances For
                                                                                                                        @[inline]

                                                                                                                        The NeedsKinds which demand the public scope after taking into account public ⊆ private on both ends. This is simply NeedsKind.all, but can help record why we're using it.

                                                                                                                        Instances For
                                                                                                                          @[inline]

                                                                                                                          The scope (directly) demanded by the NeedsKind.

                                                                                                                          Instances For
                                                                                                                            @[inline]

                                                                                                                            The scope targeted by the NeedsKind.

                                                                                                                            Instances For
                                                                                                                              @[inline]

                                                                                                                              Whether k places the src in the tgt visibility, after taking into account public ⊆ private on both ends. Note that we abstractly consider NeedsKind to be a single arrow between scopes (i.e. privOfPriv only relates the private scope to the private scope), but in this function we allow linearization (i.e. composition with public ↪ private)

                                                                                                                              Instances For

                                                                                                                                Whether k yields something in the scope tgt. This is always true when tgt is .private thanks to public ⊆ private on the target side, and is k.isExported when .public.

                                                                                                                                Instances For

                                                                                                                                  Whether k demands something in the scope src. This is always true when src is .public thanks to public ⊆ private on the source side, and is k.isAll when .private.

                                                                                                                                  Instances For
                                                                                                                                    def ImportGraph.Shake.NeedsKind.andThen (k₁ k₂ : NeedsKind) (connectable : k₁.target = k₂.source := by grind) :
                                                                                                                                    Instances For
                                                                                                                                      @[simp]
                                                                                                                                      theorem ImportGraph.Shake.NeedsKind.target_andThen_eq_right_target (k₁ k₂ : NeedsKind) (connectable : k₁.target = k₂.source) :
                                                                                                                                      (k₁.andThen k₂ ⋯).target = k₂.target
                                                                                                                                      @[simp]
                                                                                                                                      theorem ImportGraph.Shake.NeedsKind.source_andThen_eq_left_source (k₁ k₂ : NeedsKind) (connectable : k₁.target = k₂.source) :
                                                                                                                                      (k₁.andThen k₂ ⋯).source = k₁.source
                                                                                                                                      @[simp]
                                                                                                                                      theorem ImportGraph.Shake.NeedsKind.andThen_assoc (k₁ k₂ k₃ : NeedsKind) (connectable₁₂ : k₁.target = k₂.source) (connectable₂₃ : k₂.target = k₃.source) :
                                                                                                                                      (k₁.andThen k₂ ⋯).andThen k₃ ⋯ = k₁.andThen (k₂.andThen k₃ ⋯) ⋯

                                                                                                                                      The NeedsKind that represents a connection from src to tgt, with tgt the importing file. E.g., connecting? .public .private is the NeedsKind that imports a public scope into a private scope.

                                                                                                                                      Instances For