bolt/rules/digest.bend checks
raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/bolt/rules/digest.bend as Digest
bolt/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 (bolt/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
defs -- and the phases run over these, which are strings and cheap to copy.
8 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
Types
type Mention source · line 22 · raw
Data
a law names an item of a module (a type is covered by any mention of its module)
Mention@path:String -> @name:String -> Mention
type Top source · line 26 · raw
Data
a top-level def or type, by kind, name and the line it starts on
Top@kind:0x729eecea86ea5a2cdba3a2856a313bca/syntax/outline.ItemKind -> @name:String -> @line:U32 -> Top
type Unsafe source · line 30 · raw
Data
an @unsafe def and where its @ is
Unsafe@name:String -> @line:U32 -> @col:U32 -> Unsafe
type Digest source · line 37 · 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 law rule lets it off, its top-level items, what
its own laws name, the files it imports, and its @unsafe 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> -> Digest
type Alias source · line 45 · raw
Data
an import alias and the path it names
Alias@name:String -> @path:String -> Alias
Definitions
def aliases source · line 49 · raw
@items:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/outline.Item> -> @+from:String -> List<&2, Alias>
the aliases a file imports
def alias_path source · line 59 · raw
@as:List<&2, Alias> -> @+name:String -> Maybe<&2, String>
the path an alias names, when it is one
def mention source · line 69 · raw
@m:Maybe<&2, String> -> @+file:String -> @+t:String -> Mention
a name in a law as a mention: M.join is join of what M imports; a
plain name is of the law's own file
def mentions source · line 77 · raw
@toks:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/lex.Tok> -> @+as:List<&2, Alias> -> @+file:String -> List<&2, Mention>
every name among the tokens, as a mention
def law_mentions source · line 87 · raw
@root:0x729eecea86ea5a2cdba3a2856a313bca/syntax/tree.Node -> @+as:List<&2, Alias> -> @+file:String -> List<&2, Mention>
the mentions of every law statement of a tree
def top_items source · line 101 · raw
@items:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/outline.Item> -> List<&2, Top>
the top-level defs and types, by name and line: what the law rule grades
def is_exempt source · line 113 · raw
@+p:String -> @text:String -> Bool
a law file, a test, or a module that touches IO: not under law
def significant source · line 118 · raw
@toks:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/lex.Tok> -> List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/lex.Tok>
the significant tokens: no space, newline or comment
def unsafe_name source · line 127 · raw
@toks:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/lex.Tok> -> Maybe<&2, String>
the name after unsafe def, when the tokens run so
def push source · line 135 · raw
@m:Maybe<&2, String> -> @+l:U32 -> @+c:U32 -> @more:List<&2, Unsafe> -> List<&2, Unsafe>
an @ that heads an unsafe def, onto the others
def unsafe_defs source · line 143 · raw
@toks:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/lex.Tok> -> List<&2, Unsafe>
every @ unsafe def name run of tokens, on one line or two
def of source · line 155 · raw
@s:0x729eecea86ea5a2cdba3a2856a313bca/bolt/src.Src -> Digest
one parsed file read down to its digest
def all source · line 164 · raw
@ss:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/bolt/src.Src> -> List<&2, Digest>
every file the linter read, in one pass, in order
def edges source · line 172 · raw
@ds:List<&2, Digest> -> List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/bolt/rules/imports.Edge>
the import graph of the files, built once for every closure taken over it