~/bend-docscommunity

src/rules/digest.bend checks

raw source on the hub · import bolt@1.21.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.

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 ./correctness/foreign.bend as Foreign
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 Unsafe source · line 39 · 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

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

type Alias source · line 60 · raw

Data

an import alias and the path it names

type Span source · line 84 · 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 64 · raw

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

the aliases a file imports

def alias_path source · line 74 · raw

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

the path an alias names, when it is one

def spans source · line 89 · raw

@root:0xcb00b2b8895301b86fb365a9ceb6e119/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 101 · raw

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

is the line in one of the spans?

def aliased source · line 109 · 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 119 · raw

@tt:0xcb00b2b8895301b86fb365a9ceb6e119/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 130 · raw

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

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

the uses the binder recorded

def ctors source · line 150 · raw

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

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

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

def after source · line 166 · raw

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

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

def upto source · line 174 · raw

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

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

def past source · line 182 · raw

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

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

def next_line source · line 191 · raw

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

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

@ds:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/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 224 · raw

@items:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/outline.Item> -> @+us:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/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 251 · 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 255 · raw

@toks:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/lex.Tok> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/lex.Tok>

the significant tokens: no space, newline or comment

def unsafe_name source · line 264 · raw

@toks:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/lex.Tok> -> Maybe<&2, String>

the name after unsafe def, when the tokens run so

def push source · line 272 · 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 280 · raw

@toks:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/lex.Tok> -> List<&2, Unsafe>

every @ unsafe def name run of tokens, on one line or two

def foreign.push source · line 289 · raw

@mm:Maybe<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/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 303 · raw

@root:0xcb00b2b8895301b86fb365a9ceb6e119/src/syntax/tree.Node -> List<&2, Unsafe>

every top-level foreign def, where its header starts

def doc_at source · line 318 · raw

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

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

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

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

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

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

def stated source · line 374 · raw

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

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

one parsed file read down to its digest

def all source · line 393 · raw

@ss:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src> -> List<&2, Digest>

every file the linter read, in one pass, in order

def edges source · line 401 · raw

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

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