Plan.is_name: def of ezx@1.11.0.0 Import: import ezx@1.11.0.0/src/pub/plan.bend as Plan Lines 45-59 of ezx@1.11.0.0/src/pub/plan.bend: https://jend.leeeet.dev/read.txt?path=ezx@1.11.0.0/src/pub/plan.bend&start_line=45&end_line=59 import Base import ezx@1.11.0.0/src/git/git.bend as G # whether a line is a `0x` package name and nothing else. Anchored at both # ends: the prefix, the exact length, and every character after the prefix one # a lowercase hex digest may hold. `git/git.bend` already walks a hex string # for `is_rev`, and its walk stops at the first character that is not hex. # # The lines bend prints around its answer fail this, and `pub/LAWS.bend` says # so for the two that hold the name, rather than leaving it to a reading of # bend's source: `publishing N files, ... as 0x... (mining its proof of work)` # and `import 0x.../entry.bend as Name` each start with something that is not # `0x`. The terms notice and the license line bend 2.0.27 prints first # (`Publishing to BendHub: ...`, `License: ...`) start with a word too. def is_name(+word: String) -> Bool: Bool.and(String.starts_with(word, "0x"), Bool.and(Nat.is_eq(String.length(word), name.length()), G.hex.all(String.to_list(String.drop(word, 2n))))) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.drop https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.length https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.starts_with https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.to_list https://jend.leeeet.dev/definition.txt?path=ezx@1.11.0.0/src/git/git.bend&name=hex.all https://jend.leeeet.dev/definition.txt?path=ezx@1.11.0.0/src/pub/plan.bend&name=name.length