symbol-parser-0.3.0: Type level string parser combinators
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Type.Char.Digits

Description

Parse digits from type-level Chars.

A Nothing indicates the given Char was not a valid digit for the given base.

Synopsis

Documentation

type family ParseBinaryDigit (ch :: Char) :: Maybe Natural where ... Source #

Parse a binary digit (0 or 1).

type family ParseOctalDigit (ch :: Char) :: Maybe Natural where ... Source #

Parse an octal digit (0-7).

type family ParseDecimalDigit (ch :: Char) :: Maybe Natural where ... Source #

Parse a decimal digit (0-9).

type family ParseHexDigit (ch :: Char) :: Maybe Natural where ... Source #

Parse a hexadecimal digit (0-9A-Fa-f).

Both upper and lower case are permitted.

Equations

ParseHexDigit '0' = Just 0 
ParseHexDigit '1' = Just 1 
ParseHexDigit '2' = Just 2 
ParseHexDigit '3' = Just 3 
ParseHexDigit '4' = Just 4 
ParseHexDigit '5' = Just 5 
ParseHexDigit '6' = Just 6 
ParseHexDigit '7' = Just 7 
ParseHexDigit '8' = Just 8 
ParseHexDigit '9' = Just 9 
ParseHexDigit 'a' = Just 10 
ParseHexDigit 'A' = Just 10 
ParseHexDigit 'b' = Just 11 
ParseHexDigit 'B' = Just 11 
ParseHexDigit 'c' = Just 12 
ParseHexDigit 'C' = Just 12 
ParseHexDigit 'd' = Just 13 
ParseHexDigit 'D' = Just 13 
ParseHexDigit 'e' = Just 14 
ParseHexDigit 'E' = Just 14 
ParseHexDigit 'f' = Just 15 
ParseHexDigit 'F' = Just 15 
ParseHexDigit _ = Nothing