src/rules/digest.bend checks
raw source on the hub · import bolt@1.22.0.0/src/rules/digest.bend as Digest
src/rules/digest: one small reading of each file for the project rules.
A project rule sees every file at once, and a + reuse of that list copies
it: handed the parsed Src (src/src.bend), each extra use duplicated every
file's text, tokens and tree, and the pair of project rules grew faster than
the file count (100 files cost 362 s that way). So each file is read down
once to what those rules ask of it -- its path, its top-level defs and types
by name and line, what its laws name, what it imports, and its @unsafe
and foreign defs -- and the phases run over these, which are strings and cheap to copy.
13 imports
import Base import ../src.bend as Src import ../syntax/lex.bend as Lex import ../syntax/tree.bend as Tree import ../syntax/bind.bend as Bind import ../syntax/outline.bend as Outline import ../lazy/lazy.bend as Lazy import ./imports.bend as Imports import ./laws/closed.bend as Closed import ../paths.bend as Paths import ../role.bend as Role import ./correctness/foreign.bend as Foreign import ./calls.bend as Calls
Types
type Mention source · line 27 · raw
Data
a law names an item of a module: its path and its name
Mention@path:String -> @name:String -> Mention
type Top source · line 34 · raw
Data
a top-level def or type, by kind, name and the line it starts on, with a type's constructors by name (none for a def), and what the uses on its lines name (its calls, for a def): each as the binder resolved it, an item of the file or one behind an import alias
Top@kind:0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.ItemKind -> @name:String -> @line:U32 -> @ctors:List<&2, String> -> @calls:List<&2, Mention> -> Top
type Unsafe source · line 40 · raw
Data
a def a proof may not reach (bend 2.0.32): an @unsafe def, where its
@ is, or a foreign def (its body only import "./x.c" / import
"./x.js" lines), where its header starts; foreign says which
Unsafe@name:String -> @line:U32 -> @col:U32 -> @foreign:Bool -> Unsafe
type Law source · line 45 · raw
Data
a law of a LAWS.bend: its name, the line it starts on, whether it binds
(a for or exs line), and the lines of its comment block, # dropped
Law@name:String -> @line:U32 -> @binds:Bool -> @doc:List<&2, String> -> Law
type Digest source · line 52 · raw
Data
one file as the project rules see it: its path as given and normalized, its
directory, whether it states laws (LAWS.bend) or proves them too
(PROOF.bend), whether the coverage rule lets it off, its top-level items, what
its own laws name, the files it imports, its @unsafe and foreign defs
Digest@path:String -> @norm:String -> @dir:String -> @is_laws:Bool -> @is_law_file:Bool -> @exempt:Bool -> @tops:List<&2, Top> -> @says:List<&2, Mention> -> @deps:List<&2, String> -> @unsafes:List<&2, Unsafe> -> @laws:List<&2, Law> -> Digest
type Alias source · line 61 · raw
Data
an import alias and the path it names
Alias@name:String -> @path:String -> Alias
type Span source · line 85 · raw
Data
the lines a quantified law's statement spans: from its header's first token to its body's last
Span@from:U32 -> @upto:U32 -> Span
Definitions
def aliases source · line 65 · raw
@items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> @+from:String -> List<&2, Alias>
the aliases a file imports
def alias_path source · line 75 · raw
@as:List<&2, Alias> -> @+name:String -> Maybe<&2, String>
the path an alias names, when it is one
def spans source · line 90 · raw
@root:0xf2df9c564649a8f27ab619d885418944/src/syntax/tree.Node -> List<&2, Span>
the spans of every quantified law of a tree, in order. A closed law spans nothing (it covers one input, not the def)
def within source · line 102 · raw
@ss:List<&2, Span> -> @+ln:U32 -> Bool
is the line in one of the spans?
def aliased source · line 110 · raw
@mm:Maybe<&2, String> -> @+name:String -> @more:List<&2, Mention> -> List<&2, Mention>
an item behind an alias, when an import names the alias, onto the others
def target source · line 120 · raw
@tt:0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Target -> @+as:List<&2, Alias> -> @+file:String -> @more:List<&2, Mention> -> List<&2, Mention>
what the binder resolved a use to, as a mention onto the others: an item of the law's own file, or an item of the file an import alias names; nothing for a binder, a free name, or an alias no import names
def mentions source · line 131 · raw
@us:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use> -> @+ss:List<&2, Span> -> @+as:List<&2, Alias> -> @+file:String -> List<&2, Mention>
the mentions of every use the binder records in the statement of a quantified law, in order. Its header's own name is a binder, not a use
def uses.of source · line 141 · raw
@bb:0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Bound -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use>
the uses the binder recorded
def ctors source · line 151 · raw
@items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> List<&2, String>
the names of the constructors the items open with: a type's, since the outline lists them right after it
def before source · line 159 · raw
@us:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use> -> @+at:U32 -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use>
the uses, in order, before the first one at or past the line
def after source · line 167 · raw
@us:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use> -> @+at:U32 -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use>
the uses from the first one at or past the line on
def upto source · line 175 · raw
@us:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use> -> @mm:Maybe<&2, U32> -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use>
the uses before the line, when there is one; else all of them
def past source · line 183 · raw
@us:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use> -> @mm:Maybe<&2, U32> -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use>
the uses from the line on, when there is one; else none
def next_line source · line 192 · raw
@items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> Maybe<&2, U32>
the line of the next item that ends an item's lines: any but a constructor, which the outline lists inside its type
def called source · line 202 · raw
@us:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use> -> @+as:List<&2, Alias> -> @+file:String -> List<&2, Mention>
what the uses name, in order: an item of the file, or one behind an alias
def proofs source · line 213 · raw
@ds:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/rules/calls.Def> -> List<&2, String>
the names of the top-level defs that are proofs (Calls.proof: one that returns a proof, or one written with no type, which is how Bend fills the law named f). The law states their property, so the coverage rule neither grades them nor walks through them
def ranged source · line 225 · raw
@items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> @+us:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Use> -> @+as:List<&2, Alias> -> @+file:String -> @+ps:List<&2, String> -> List<&2, Top>
the top-level defs and types, by name and line, less the defs that are proofs (ps): what the coverage rule grades. The uses are read in order, once: each item but a constructor takes those before the next such item's line, and a def or a type keeps what they name (a def's calls)
def is_exempt source · line 252 · raw
@+pp:String -> Bool
a law file or a test, by its path alone: not under law. Nothing the file's text mentions exempts it; IO is not an exemption, since an IO equality is a law.
def significant source · line 256 · raw
@toks:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/lex.Tok> -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/lex.Tok>
the significant tokens: no space, newline or comment
def unsafe_name source · line 265 · raw
@toks:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/lex.Tok> -> Maybe<&2, String>
the name after unsafe def, when the tokens run so
def push source · line 273 · raw
@mm:Maybe<&2, String> -> @+ll:U32 -> @+cc:U32 -> @more:List<&2, Unsafe> -> List<&2, Unsafe>
an @ that heads an unsafe def, onto the others
def unsafe_defs source · line 281 · raw
@toks:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/lex.Tok> -> List<&2, Unsafe>
every @ unsafe def name run of tokens, on one line or two
def foreign.push source · line 290 · raw
@mm:Maybe<&2, 0xf2df9c564649a8f27ab619d885418944/src/rules/correctness/foreign.Lanes> -> @+name:String -> @+ll:U32 -> @+cc:U32 -> @more:List<&2, Unsafe> -> List<&2, Unsafe>
a foreign def, when its body is one (Foreign.lanes), onto the others
def foreign_defs source · line 304 · raw
@root:0xf2df9c564649a8f27ab619d885418944/src/syntax/tree.Node -> List<&2, Unsafe>
every top-level foreign def, where its header starts
def doc_at source · line 319 · raw
@items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> @+at:U32 -> String
the doc of the item on a line; the items are in line order, so the search stops at it
def from_line.stop source · line 327 · raw
@items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> @+at:U32 -> Bool
does the first item sit on or after a line (from_line stops there)?
def from_line source · line 337 · raw
@items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> @+at:U32 -> @+stop:Bool -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item>
the items from the first on or after a line; the items are in line order, and so are a tree's laws, so an item this drops lies above every later law too. stop is from_line.stop of items, carried so the step stays a loop
def laws_of source · line 351 · raw
@root:0xf2df9c564649a8f27ab619d885418944/src/syntax/tree.Node -> @+items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> List<&2, Law>
every law of a tree, with whether it binds and its doc lines. items is a cursor: each law's search starts where the last one stopped, so the items are read once over all the laws, not once per law
def laws.in source · line 364 · raw
@is_laws:Bool -> @root:0xf2df9c564649a8f27ab619d885418944/src/syntax/tree.Node -> @items:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/syntax/outline.Item> -> List<&2, Law>
the laws of a LAWS.bend; no other file states any
def stated source · line 375 · raw
@is_laws:Bool -> @root:0xf2df9c564649a8f27ab619d885418944/src/syntax/tree.Node -> @bound:0xf2df9c564649a8f27ab619d885418944/src/syntax/bind.Bound -> @as:List<&2, Alias> -> @file:String -> List<&2, Mention>
what a file's laws name: only a LAWS.bend states laws that cover a def
def of source · line 383 · raw
@s2:0xf2df9c564649a8f27ab619d885418944/src/src.Src -> Digest
one parsed file read down to its digest
def of.role source · line 395 · raw
@+rr:0xf2df9c564649a8f27ab619d885418944/src/role.Role -> @s2:0xf2df9c564649a8f27ab619d885418944/src/src.Src -> Digest
one parsed file read down to its digest, told its role (src/role.bend): a law file states the laws that cover defs, and a law or proof file is exempt
def of.marked source · line 407 · raw
@+ms:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/role.Mark> -> @s2:0xf2df9c564649a8f27ab619d885418944/src/src.Src -> Digest
one parsed file's digest, told its role among the marks (src/role.bend)
def all.role source · line 413 · raw
@+ms:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/role.Mark> -> @ss:List<&2, 0xf2df9c564649a8f27ab619d885418944/src/src.Src> -> List<&2, Digest>
every file the linter read, each with its role among the marks, in one pass, in order
def edges source · line 421 · raw
@ds:List<&2, Digest> -> List<&2, 0xf2df9c564649a8f27ab619d885418944/src/rules/imports.Edge>
the import graph of the files, built once for every closure taken over it