src/lint/world.bend checks
raw source on the hub · import bolt@1.58.0.0/src/lint/world.bend as World
src/lint/world: everything bolt reads, as one value. The planner
(src/lint/plan.bend) is a pure function of a World; the interpreter
(src/lint.bend) gathers one, answering each question the planner asks by
IO, and prints the plan the planner returns. The design is
docs/rfc/bolt-lint-planner.md.
The World holds only what the lint reads: the paths named on the command line, the working directory they are named from, and every answer the interpreter gave. A question with no answer yet reads as a directory with no entries or a file that cannot be read.
2 imports
import Base import ../lazy/lazy.bend as Lazy
Types
type Ask source · line 16 · raw
Data
a question the planner asks. Each is answered by one IO action: a directory listed (src/walk/), or a file read (src/lsp/files/).
Entries@dir:String -> Ask
Contents@path:String -> Ask
type Answer source · line 23 · raw
Data
the answer to one question. A directory that cannot be opened lists as
empty, as src/walk/dir.c answers. A text asked of a path that is a
directory is Directory, not a read: it has no text.
Listed@names:List<&2, String> -> Answer
Read@text:String -> Answer
UnreadAnswer
DirectoryAnswer
type Reply source · line 30 · raw
Data
one question, answered
Reply@ask:Ask -> @answer:Answer -> Reply
type World source · line 36 · raw
Data
everything bolt reads: the paths named on the command line, the working
directory (absolute) that relative paths are named from, and every answer
the interpreter gave, in the order it gave them
World@paths:List<&2, String> -> @cwd:String -> @replies:List<&2, Reply> -> World
type Ix source · line 135 · raw
Data
The replies, indexed. A question is looked up once per source, per bolt.bend candidate of each directory, and a scan of every reply for each is the questions times the replies: on a project of 4,062 files, 4.4 s to find which bolt.bend grades each of its 733 directories, and 3 s to read their configs. So the replies are put in a trie on the low bits of each question's number, each leaf the replies whose question lands there, in their order, and a lookup scans only its own leaf. Two questions alike have the same number, so the leaf holds every reply the scan would stop at, and its first such reply is the scan's (proofs/lemmas/ReplyIndex.bend).
INoneIx
ILeaf@rs:List<&2, Reply> -> Ix
INode@lo:Ix -> @hi:Ix -> Ix
Definitions
def paths.of source · line 40 · raw
@world:World -> List<&2, String>
the paths named on the command line
def cwd.of source · line 45 · raw
@world:World -> String
the working directory the run was started in
def ask.eq source · line 50 · raw
@a:Ask -> @b:Ask -> Bool
whether two questions are the same question
def answer.in source · line 62 · raw
@rs:List<&2, Reply> -> @+ask:Ask -> Maybe<&2, Answer>
the first answer given to a question
def answer source · line 70 · raw
@world:World -> @+ask:Ask -> Maybe<&2, Answer>
the answer a World holds for a question, None while there is none
def answered source · line 75 · raw
@world:World -> @+ask:Ask -> Bool
whether a World answers a question
def listing.answer source · line 79 · raw
@a:Answer -> List<&2, String>
a listing's names; anything else lists nothing
def listing.got source · line 90 · raw
@m:Maybe<&2, Answer> -> List<&2, String>
def listing source · line 99 · raw
@world:World -> @dir:String -> List<&2, String>
a directory's entries, a sub-directory's name ending in "/"; none while the directory is not listed yet
def text.answer source · line 103 · raw
@a:Answer -> Maybe<&2, String>
a read's text; anything else is no text
def text.got source · line 114 · raw
@m:Maybe<&2, Answer> -> Maybe<&2, String>
def text source · line 123 · raw
@world:World -> @path:String -> Maybe<&2, String>
a file's text, or None when it could not be read, is a directory, or is not read yet
def ix.depth source · line 141 · raw
Nat
how many bits of a question's number the index branches on
def ix.key.go source · line 145 · raw
@name:String -> @+acc:U32 -> U32
a path's number: its chars folded, each onto 31 times the number so far
def ix.key source · line 153 · raw
@a:Ask -> U32
a question's number: its path's
def ix.rs source · line 161 · raw
@ix:Ix -> List<&2, Reply>
the replies at a leaf, none elsewhere
def ix.pick source · line 171 · raw
@b:Bool -> @lo:Ix -> @hi:Ix -> Ix
the half a bit picks: an even bit the low half
def ix.near source · line 179 · raw
@b:Bool -> @ix:Ix -> Ix
the half of a node a bit picks; none below anything else
def ix.join source · line 187 · raw
@b:Bool -> @sub:Ix -> @far:Ix -> Ix
a node from the half a bit picks and the other half
def ix.put source · line 195 · raw
@d:Nat -> @+k:U32 -> @+ix:Ix -> @r:Reply -> Ix
a reply put at the front of the leaf its number's low bits lead to
def ix.at source · line 204 · raw
@d:Nat -> @+k:U32 -> @ix:Ix -> List<&2, Reply>
the replies at the leaf a number's low bits lead to
def ix.of source · line 212 · raw
@rs:List<&2, Reply> -> Ix
the index of these replies, each leaf in their order
def ix.world source · line 220 · raw
@world:World -> Ix
a World's replies, indexed
def answer.ix source · line 225 · raw
@ix:Ix -> @+ask:Ask -> Maybe<&2, Answer>
the first answer to a question, read off its leaf: answer's
def text.ix source · line 229 · raw
@ix:Ix -> @path:String -> Maybe<&2, String>
a file's text, read off the index: text's