defs.bend checks
raw source on the hub · import lawful-fields@0.1.1.0/defs.bend as Defs
3 imports
import Base import lawful-words@0.1.0.0/defs.bend as W import lawful-bytes@0.1.1.0/defs.bend as D
Definitions
def split.push source · line 9 · raw
@+c:U32 -> @ps:List<&2, List<&2, U32>> -> List<&2, List<&2, U32>>
def split.fin source · line 16 · raw
@+c:U32 -> @r:List<&2, List<&2, U32>> -> @cut:Bool -> List<&2, List<&2, U32>>
def split source · line 25 · raw
@xs:List<&2, U32> -> @+sep:U32 -> List<&2, List<&2, U32>>
The pieces of xs between separators, as Base's String.split does for text: always at least one piece, so [] gives [[]] and [sep] gives [[], []].
def digit.if source · line 32 · raw
@+x:U32 -> @ok:Bool -> Maybe<&2, Nat>
def digit source · line 40 · raw
@+x:U32 -> Maybe<&2, Nat>
The value of a decimal digit byte ('0' is 48).
def dec.push source · line 43 · raw
@acc:Maybe<&2, Nat> -> @d:Maybe<&2, Nat> -> Maybe<&2, Nat>
def dec.go source · line 50 · raw
@xs:List<&2, U32> -> @acc:Maybe<&2, Nat> -> Maybe<&2, Nat>
def dec source · line 59 · raw
@xs:List<&2, U32> -> Maybe<&2, Nat>
A decimal number: one or more digits (leading zeros allowed), nothing else; any size (framebender's Pos.read on text is the same function).
def decb.if source · line 66 · raw
@+n:Nat -> @fits:Bool -> Maybe<&2, Nat>
def decb.of source · line 73 · raw
@m:Maybe<&2, Nat> -> @+bound:Nat -> Maybe<&2, Nat>
def decb source · line 83 · raw
@xs:List<&2, U32> -> @+bound:Nat -> Maybe<&2, Nat>
A decimal number below bound; None otherwise. The laws use bound = 2^32 (what fits a U32), written Nat.pow(2n, 32n) in each law: the checker evaluates a constant hidden in a definition, and 2^32 in unary is too deep.
def nat_of source · line 87 · raw
@m:Maybe<&2, U32> -> Maybe<&2, Nat>
The number a Maybe<U32> stands for.
def pieces source · line 96 · raw
@es:List<&2, U32> -> @+xs:List<&2, U32> -> @+from:Nat -> List<&2, List<&2, U32>>
The pieces of xs that end at each offset of es, the first starting at from and each next one just after the previous end (where the separator was).
def within source · line 104 · raw
@es:List<&2, U32> -> @+from:Nat -> @+to:Nat -> Bool
Every offset in es lies in from .. to.
def count.if source · line 111 · raw
@hit:Bool -> @+n:Nat -> Nat
def count source · line 119 · raw
@xs:List<&2, U32> -> @+sep:U32 -> Nat
How many times sep occurs in xs.
def join.go source · line 126 · raw
@ps:List<&2, List<&2, U32>> -> @+sep:U32 -> List<&2, U32>
def join source · line 136 · raw
@ps:List<&2, List<&2, U32>> -> @+sep:U32 -> List<&2, U32>
The pieces joined with sep between them. join undoes split: join(split(xs, sep), sep) == xs (the other way round fails when a piece holds sep).
def text source · line 145 · raw
@xs:List<&2, U32> -> String
Bytes as text and back: one Char per byte (Chr{b}), with no decoding (the way framebender reads files). For text whose characters are all below 256.
def texts source · line 152 · raw
@ps:List<&2, List<&2, U32>> -> List<&2, String>
def codes source · line 159 · raw
@s:String -> List<&2, U32>
def show source · line 167 · raw
@n:U32 -> List<&2, U32>
The decimal digits of a number, as bytes (Base's Nat.show).
def ends source · line 172 · raw
@ps:List<&2, List<&2, U32>> -> @+from:Nat -> List<&2, Nat>
The end offset of each piece, the first piece starting at from and each next one just after the previous end.
def nats source · line 181 · raw
@es:List<&2, U32> -> List<&2, Nat>
The numbers words stand for.
def all_digits source · line 189 · raw
@xs:List<&2, U32> -> Bool
xs is one or more digits (any value).