lib.bend checks
raw source on the hub · import 0xf941a081d658b4ed09b0d1c5a3d26f48/lib.bend as Lib
Hex — strict hexadecimal codec for Base List<&2, U32> and String. Base-only, no termination escapes. Encoding is lowercase and octet-oriented.
1 import
import Base
Definitions
def Hex.digit source · line 6 · raw
@+n:U32 -> Char
Digits 0..15 are emitted as lowercase 0-9a-f.
def Hex.encode.byte source · line 11 · raw
@+b:U32 -> String
Encode one octet. As with Bytes.hex, only the low eight bits participate.
def Hex.encode.go source · line 17 · raw
@xs:List<&2, U32> -> String
def Hex.encode source · line 24 · raw
@xs:List<&2, U32> -> String
def Hex.value source · line 29 · raw
@+c:Char -> Maybe<&2, U32>
Convert one accepted hexadecimal character to its nibble value. Both cases are accepted; no whitespace or prefixes are accepted.
def Hex.decode.prefix source · line 43 · raw
@+hi:U32 -> @+lo:U32 -> @r:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>
Prepend one decoded octet to a successful tail; preserve failure.
def Hex.decode.pair source · line 54 · raw
@r:Maybe<&2, List<&2, U32>> -> @ma:Maybe<&2, U32> -> @mb:Maybe<&2, U32> -> Maybe<&2, List<&2, U32>>
Decode exactly two hex characters. The recursive decoder supplies r, so any malformed suffix makes the whole result None.
def Hex.decode.go source · line 66 · raw
@s:String -> Maybe<&2, List<&2, U32>>
Strict decoding: input must have even length and every character must be 0-9, a-f, or A-F. Empty input decodes to Some{Nil{}}.
def Hex.decode source · line 77 · raw
@s:String -> Maybe<&2, List<&2, U32>>