Alias for Char.isWhitespace.
$$\text{isSpace}(c) = \text{isWhitespace}(c)$$
Equations
Instances For
Test if a character is alphanumeric (letter or digit). $$\text{isAlphaNum}(c) = \text{isAlpha}(c) \lor \text{isDigit}(c)$$
Equations
- Data.Char'.isAlphaNum c = (c.isAlpha || c.isDigit)
Instances For
Test if a character is in the ASCII range $[0, 128)$. $$\text{isAscii}(c) \iff \text{ord}(c) < 128$$
Equations
- Data.Char'.isAscii c = decide (c.toNat < 128)
Instances For
Test if a character is in the Latin-1 range $[0, 256)$. $$\text{isLatin1}(c) \iff \text{ord}(c) < 256$$
Equations
- Data.Char'.isLatin1 c = decide (c.toNat < 256)
Instances For
Test if a character is printable (ASCII, non-control). $$\text{isPrint}(c) \iff \lnot\,\text{isControl}(c) \land \text{ord}(c) < 128$$ Note: this is a simplified ASCII-only version.
Equations
- Data.Char'.isPrint c = (!Data.Char'.isControl c && decide (c.toNat < 128))
Instances For
Test if a character is a hexadecimal digit: 0--9, a--f, A--F.
$$\text{isHexDigit}(c) \iff c \in [0\text{-}9] \cup [a\text{-}f] \cup [A\text{-}F]$$
Equations
Instances For
Test if a character is ASCII punctuation. $$\text{isPunctuation}(c) \iff c \in [\texttt{!}-\texttt{/}] \cup [\texttt{:}-\texttt{@}] \cup [\texttt{[}-\texttt{`}] \cup [\texttt{\{}-\texttt{~}]$$ Covers ASCII punctuation ranges: 33--47, 58--64, 91--96, 123--126.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Character to its Unicode code point. $$\text{ord}(c) = \text{toNat}(c)$$
Equations
- Data.Char'.ord c = c.toNat
Instances For
Code point to character. $$\text{chr}(n) = \text{Char.ofNat}(n)$$
Equations
Instances For
Convert a hex digit character to its numeric value, bounded below 16.
$$\text{digitToInt}(c) = \begin{cases} n - 48 & c \in [\texttt{0}\text{-}\texttt{9}] \\ n - 55 & c \in [\texttt{A}\text{-}\texttt{F}] \\ n - 87 & c \in [\texttt{a}\text{-}\texttt{f}] \\ \text{none} & \text{otherwise} \end{cases}$$
Returns Option {n : Nat // n < 16} — the proof that the digit is in $[0, 15]$
is carried in the subtype and erased at runtime.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Convert a number in $[0, 15]$ to a hex digit character. Total — no Option needed.
$$\text{intToDigit}(n) = \begin{cases} \texttt{0} + n & n \in [0, 9] \\ \texttt{a} + (n - 10) & n \in [10, 15] \end{cases}$$
The proof obligation n < 16 is required at the call site and erased at runtime.
Equations
- Data.Char'.intToDigit n _h = if n ≤ 9 then Char.ofNat (48 + n) else Char.ofNat (87 + n)
Instances For
isAlphaNum unfolds to its definition.
isSpace is an alias for isWhitespace.
Roundtrip: digitToInt (intToDigit n) = some ⟨n, h⟩ for all n < 16.
Every decimal digit is also a hex digit.
intToDigit always produces an ASCII character.