~/bend-docscommunity

src/ws/workspace.bend checks

raw source on the hub · import ezx@1.16.0.0/src/ws/workspace.bend as Workspace

ws/workspace: which directories a workspace's root ledger makes members (laws/WorkspaceMembersChosen.bend). A root ledger's [workspace] table lists members, each a directory relative to the root or <dir>/*, every directory directly under <dir>, and exclude, directories taken back out. The design is docs/rfc/ez-workspaces.md.

Everything here is pure. A path is read as its segments, the pieces between its /s, so a member, an entry and an exclusion are compared segment by segment and nothing is cut off the end of a string. What the member set is decided from is the root ledger's text and, for every ez.toml git lists under the root, the directory it is in, its [package] name and whether it has a [workspace] table of its own. The interpreter of each command that reads a workspace gathers those; it decides nothing.

3 imports
import Base
import emerging-eztoml@0.9.0.0/main.bend as E
import ../toml/toml.bend as T

Types

type Entry source · line 59 · raw

Data

one entry of members: a directory named as it is, or every directory directly under one, which <dir>/* names

type Spec source · line 201 · raw

Data

what [workspace] says: its entries and the directories it excludes

type Root source · line 207 · raw

Data

the root's ledger: one with a [package] table is a member, under its name, and one with none is a virtual root, which holds the workspace and nothing to build

type Ledger source · line 214 · raw

Data

an ez.toml git lists under the root, other than the root's own: the directory it is in, its [package] name, and whether it has a [workspace] table of its own

type Members source · line 219 · raw

Data

the member set, or why there is none: whether the root is a member, and every other member's directory

type Read source · line 408 · raw

Data

what a ledger's text says of its workspace: nothing, a [workspace] table, or why the table could not be read

Definitions

def segs.of source · line 19 · raw

@+path:String -> List<&2, String>

a path, as the segments between its /s

def segs.text source · line 23 · raw

@ss:List<&2, String> -> String

a path's segments, written back with / between them

def cut.cons source · line 27 · raw

@+head:String -> @rest:Maybe<&2, List<&2, String>> -> Maybe<&2, List<&2, String>>

a list of segments with one more in front, when there was a list

def cut.last source · line 35 · raw

@hit:Bool -> Maybe<&2, List<&2, String>>

the last segment, kept when it is the word and nothing otherwise

def cut source · line 45 · raw

@ss:List<&2, String> -> @+word:String -> Maybe<&2, List<&2, String>>

the segments before the last, when the last is the word: libs/* cut at * is libs, and cli/ez.toml cut at ez.toml is cli. A path whose last segment is another word cuts to nothing.

def entry.go source · line 64 · raw

@under:Maybe<&2, List<&2, String>> -> @+ss:List<&2, String> -> Entry

an entry, once it is known whether its last segment is *

def entry.of source · line 73 · raw

@+ss:List<&2, String> -> Entry

an entry's segments read: <dir>/* is every directory under <dir>, and anything else is the directory it names

def entry.dir source · line 77 · raw

@entry:Entry -> List<&2, String>

the directory an entry names, or the one it names the directories under

def entry.text source · line 85 · raw

@entry:Entry -> String

an entry as it was written

def seg.ok source · line 96 · raw

@+seg:String -> Bool

whether a segment can be part of a member's path: it is not empty, which a leading / or a // would make it, it is neither . nor .., which would name a directory by where it is from here, and it is not *, which only ends an entry

def segs.ok source · line 102 · raw

@ss:List<&2, String> -> Bool

whether every segment can be part of a member's path

def dir.ok source · line 112 · raw

@+ss:List<&2, String> -> Bool

whether a directory is one a workspace can name: it has a segment, and every segment is one a member's path can have

def entries.ok source · line 116 · raw

@es:List<&2, Entry> -> Bool

whether every entry names a directory a workspace can name

def entries.bad source · line 125 · raw

@es:List<&2, Entry> -> String

the first entry that names no directory a workspace can name, "" for none

def segs.eq source · line 137 · raw

@as:List<&2, String> -> @bs:List<&2, String> -> Bool

whether two paths are one, segment by segment

def one source · line 150 · raw

@ds:List<&2, String> -> Bool

whether a path is exactly one segment

def under source · line 159 · raw

@ps:List<&2, String> -> @ds:List<&2, String> -> Bool

whether a directory is directly under another: the other's segments, then exactly one more

def hit source · line 172 · raw

@entry:Entry -> @+ds:List<&2, String> -> Bool

whether an entry names a directory

def listed source · line 180 · raw

@es:List<&2, Entry> -> @+ds:List<&2, String> -> Bool

whether any entry names a directory

def has source · line 189 · raw

@xs:List<&2, List<&2, String>> -> @+ds:List<&2, String> -> Bool

whether a list of paths holds one

def ledger.dir source · line 224 · raw

@ledger:Ledger -> List<&2, String>

a ledger's directory

def ledger.name source · line 229 · raw

@ledger:Ledger -> String

a ledger's package name

def ledger.nested source · line 234 · raw

@ledger:Ledger -> Bool

whether a ledger has a [workspace] table of its own

def dirs.of source · line 239 · raw

@ls:List<&2, Ledger> -> List<&2, List<&2, String>>

the directory of every ledger, in order

def chosen source · line 247 · raw

@+spec:Spec -> @+ds:List<&2, String> -> Bool

whether a directory is a member: an entry names it and no exclusion does

def picks.put source · line 252 · raw

@keep:Bool -> @+ledger:Ledger -> @rest:List<&2, Ledger> -> List<&2, Ledger>

this ledger in front of the rest, when its directory is a member

def picks source · line 260 · raw

@+spec:Spec -> @ls:List<&2, Ledger> -> List<&2, Ledger>

every ledger whose directory is a member, in the order git listed them

def present.one source · line 269 · raw

@entry:Entry -> @+found:List<&2, List<&2, String>> -> Bool

whether an entry that names a directory as it is names one that holds a committed ez.toml. <dir>/* names whatever is there, none included.

def present source · line 277 · raw

@es:List<&2, Entry> -> @+found:List<&2, List<&2, String>> -> Bool

whether every entry naming a directory as it is names one that is there

def absent source · line 287 · raw

@es:List<&2, Entry> -> @+found:List<&2, List<&2, String>> -> String

the first entry naming a directory as it is that names none there, "" for none

def unnested source · line 296 · raw

@ls:List<&2, Ledger> -> Bool

whether no member's ledger has a [workspace] table of its own

def nested source · line 305 · raw

@ls:List<&2, Ledger> -> String

the first member whose ledger has a [workspace] table, "" for none

def names.of source · line 314 · raw

@ls:List<&2, Ledger> -> List<&2, String>

the package name of every ledger, in order

def names source · line 322 · raw

@root:Root -> @ls:List<&2, Ledger> -> List<&2, String>

the package name of every member, the root's first when it is one

def named source · line 330 · raw

@ns:List<&2, String> -> @+nn:String -> Bool

whether a list of names holds one

def distinct source · line 339 · raw

@ns:List<&2, String> -> Bool

whether no name is in the list twice

def twice source · line 348 · raw

@ns:List<&2, String> -> String

the first name in the list twice, "" for none

def root.member source · line 357 · raw

@root:Root -> Bool

whether the root is a member

def ok source · line 368 · raw

@+spec:Spec -> @+root:Root -> @+ls:List<&2, Ledger> -> Bool

whether the workspace has a member set: every entry names a directory a workspace can name, every one naming a directory as it is names one with a committed ez.toml, no member is a workspace root of its own, and no two members have one package name

def why source · line 375 · raw

@+spec:Spec -> @+root:Root -> @+ls:List<&2, Ledger> -> String

why a workspace has no member set, said for the first thing found wrong

def members.go source · line 390 · raw

@fine:Bool -> @+spec:Spec -> @+root:Root -> @+ls:List<&2, Ledger> -> Members

the member set, once it is known whether there is one

def members source · line 400 · raw

@+spec:Spec -> @+root:Root -> @+ls:List<&2, Ledger> -> Members

the members of a workspace: the root when it has a package, and the directory of every ledger an entry names and no exclusion does, or why there are none

def strs source · line 414 · raw

@items:List<&2, 0xc5d9d3e28b79ea98be22eb42c7e37802/main.Val> -> Maybe<&2, List<&2, String>>

every item of an array as text, or nothing when one is not a string

def array.val source · line 426 · raw

@val:0xc5d9d3e28b79ea98be22eb42c7e37802/main.Val -> Maybe<&2, List<&2, String>>

a value read as an array of strings

def array.at source · line 434 · raw

@hit:Bool -> @val:0xc5d9d3e28b79ea98be22eb42c7e37802/main.Val -> @rest:Maybe<&2, List<&2, String>> -> Maybe<&2, List<&2, String>>

this pair's array when its key is the key, otherwise the rest's

def array source · line 443 · raw

@rows:List<&2, 0xc5d9d3e28b79ea98be22eb42c7e37802/main.Val> -> @+key:String -> Maybe<&2, List<&2, String>>

the array a table's key holds, an absent key holding none, or nothing when the key holds something else

def entries.of source · line 453 · raw

@ts:List<&2, String> -> List<&2, Entry>

every text read as an entry

def paths.of source · line 461 · raw

@ts:List<&2, String> -> List<&2, List<&2, String>>

every text read as a path's segments

def table.go source · line 469 · raw

@ms:Maybe<&2, List<&2, String>> -> @ex:Maybe<&2, List<&2, String>> -> Read

the table, once both arrays were read

def table source · line 481 · raw

@+rows:List<&2, 0xc5d9d3e28b79ea98be22eb42c7e37802/main.Val> -> Read

a [workspace] table's rows read

def spec.at source · line 485 · raw

@hit:Bool -> @+sub:List<&2, 0xc5d9d3e28b79ea98be22eb42c7e37802/main.Val> -> @rest:Read -> Read

this table when it is [workspace], otherwise the rest's

def spec.rows source · line 493 · raw

@rows:List<&2, 0xc5d9d3e28b79ea98be22eb42c7e37802/main.Val> -> Read

the [workspace] table among a document's rows, or none

def spec.of source · line 504 · raw

@text:String -> Read

what a ledger's text says of its workspace. A ledger that does not parse says nothing here; the command that reads it refuses it as it always has.

def sect.name source · line 508 · raw

@sect:0x71927e9fe3c5d91fa7a64d2340a0fdac/src/toml/toml.Sect -> String

a section's name

def sect.has source · line 513 · raw

@ss:List<&2, 0x71927e9fe3c5d91fa7a64d2340a0fdac/src/toml/toml.Sect> -> @+name:String -> Bool

whether a document has a section of this name

def pairs.at source · line 522 · raw

@sect:0x71927e9fe3c5d91fa7a64d2340a0fdac/src/toml/toml.Sect -> @rest:List<&2, 0x71927e9fe3c5d91fa7a64d2340a0fdac/src/toml/toml.Kv> -> @+name:String -> List<&2, 0x71927e9fe3c5d91fa7a64d2340a0fdac/src/toml/toml.Kv>

this section's pairs when its name matches, otherwise the rest's

def pairs.of source · line 527 · raw

@ss:List<&2, 0x71927e9fe3c5d91fa7a64d2340a0fdac/src/toml/toml.Sect> -> @+name:String -> List<&2, 0x71927e9fe3c5d91fa7a64d2340a0fdac/src/toml/toml.Kv>

the pairs of the section with this name, or none

def root.of source · line 536 · raw

@+text:String -> Root

the root, read from its ledger's text: a member under its [package] name when it has a [package] table, a virtual root when it has none

def ledger.some source · line 542 · raw

@ds:List<&2, String> -> @nn:String -> @ww:Bool -> Maybe<&2, Ledger>

a ledger under a directory of at least one segment

def ledger.go source · line 551 · raw

@dir:Maybe<&2, List<&2, String>> -> @nn:String -> @ww:Bool -> Maybe<&2, Ledger>

the ledger, once its directory is known: the root's own ez.toml cuts to no segments, and is not one of these

def ledger.of source · line 562 · raw

@+path:String -> @+text:String -> Maybe<&2, Ledger>

a committed ez.toml under the root, read: the directory it is in, which is its path with the last segment cut, its [package] name, and whether it has a [workspace] table. A path that is not an ez.toml under a directory is none.