~/bend-docscommunity

src/rules/digest.bend checks

raw source on the hub · import bolt@1.53.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 laws -- and the phases run over these, which are strings and cheap to copy.

12 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 ./calls.bend as Calls

Types

type Mention source · line 26 · raw

Data

a law names an item of a module: its path and its name

type Top source · line 33 · 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

type Law source · line 38 · 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

type Digest source · line 45 · 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, and its laws

type Alias source · line 54 · raw

Data

an import alias and the path it names

type Span source · line 86 · raw

Data

the lines a quantified law's statement spans: from its header's first token to its body's last

Definitions

def aliases source · line 58 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/outline.Item> -> @+from:String -> List<&2, Alias>

the aliases a file imports

def alias_path.go source · line 69 · raw

@as:List<&2, Alias> -> @+name:String -> @hit:Maybe<&2, String> -> Maybe<&2, String>

the path an alias names, when it is one; hit: the alias before as was the name, so the search stops there

def alias_path source · line 81 · raw

@as:List<&2, Alias> -> @+name:String -> Maybe<&2, String>

the path an alias names, when it is one: the first alias of the name

def spans source · line 91 · raw

@root:0xb2e58a591ad27179e8a01dfbb0974cf3/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 103 · raw

@ss:List<&2, Span> -> @+ln:U32 -> Bool

is the line in one of the spans?

def aliased source · line 111 · 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 121 · raw

@tt:0xb2e58a591ad27179e8a01dfbb0974cf3/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 132 · raw

@us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 142 · raw

@bb:0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Bound -> List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use>

the uses the binder recorded

def ctors source · line 152 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 160 · raw

@us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use> -> @+at:U32 -> List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use>

the uses, in order, before the first one at or past the line

def after source · line 168 · raw

@us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use> -> @+at:U32 -> List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use>

the uses from the first one at or past the line on

def upto source · line 176 · raw

@us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use> -> @mm:Maybe<&2, U32> -> List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use>

the uses before the line, when there is one; else all of them

def past source · line 184 · raw

@us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use> -> @mm:Maybe<&2, U32> -> List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use>

the uses from the line on, when there is one; else none

def next_line source · line 193 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 203 · raw

@us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 214 · raw

@ds:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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.spec source · line 228 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/outline.Item> -> @+us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use> -> @+as:List<&2, Alias> -> @+file:String -> @+ps:List<&2, String> -> List<&2, Top>

ranged, asking the list of the proofs' names where ranged asks their index: the walk the laws are proved on (proofs/LawNamesEveryItem.bend shows the two equal). 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 ranged source · line 259 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/outline.Item> -> @+us:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Use> -> @+as:List<&2, Alias> -> @+file:String -> @+px:0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/bind.Index -> List<&2, Top>

the top-level defs and types, by name and line, less the defs that are proofs (px, the index of their names: a scan of the names for each def is the defs times the proofs, 18 s on a generated file of 21,344 untyped defs and 0.2 s through the index): 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 286 · 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 doc_at source · line 294 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 302 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 312 · raw

@items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/outline.Item> -> @+at:U32 -> @+stop:Bool -> List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 326 · raw

@root:0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/tree.Node -> @+items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 339 · raw

@is_laws:Bool -> @root:0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/tree.Node -> @items:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/outline.Item> -> List<&2, Law>

the laws of a LAWS.bend; no other file states any

def stated source · line 350 · raw

@is_laws:Bool -> @root:0xb2e58a591ad27179e8a01dfbb0974cf3/src/syntax/tree.Node -> @bound:0xb2e58a591ad27179e8a01dfbb0974cf3/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 358 · raw

@s2:0xb2e58a591ad27179e8a01dfbb0974cf3/src/src.Src -> Digest

one parsed file read down to its digest

def of.role source · line 370 · raw

@+rr:0xb2e58a591ad27179e8a01dfbb0974cf3/src/role.Role -> @s2:0xb2e58a591ad27179e8a01dfbb0974cf3/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 382 · raw

@+ms:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/role.Mark> -> @s2:0xb2e58a591ad27179e8a01dfbb0974cf3/src/src.Src -> Digest

one parsed file's digest, told its role among the marks (src/role.bend)

def all.role source · line 388 · raw

@+ms:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/role.Mark> -> @ss:List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/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 396 · raw

@ds:List<&2, Digest> -> List<&2, 0xb2e58a591ad27179e8a01dfbb0974cf3/src/rules/imports.Edge>

the import graph of the files, built once for every closure taken over it