rio- A standard library for Haskell
Safe HaskellSafe-Inferred



Unicode Char partial functions. Import as:

import qualified RIO.Char.Partial as C'

Single digit characters

digitToInt :: Char -> Int #

Convert a single digit Char to the corresponding Int. This function fails unless its argument satisfies isHexDigit, but recognises both upper- and lower-case hexadecimal digits (that is, '0'..'9', 'a'..'f', 'A'..'F').



Characters '0' through '9' are converted properly to 0..9:

>>> map digitToInt ['0'..'9']

Both upper- and lower-case 'A' through 'F' are converted as well, to 10..15.

>>> map digitToInt ['a'..'f']
>>> map digitToInt ['A'..'F']

Anything else throws an exception:

>>> digitToInt 'G'
*** Exception: Char.digitToInt: not a digit 'G'
>>> digitToInt '♥'
*** Exception: Char.digitToInt: not a digit '\9829'

intToDigit :: Int -> Char #

Convert an Int in the range 0..15 to the corresponding single digit Char. This function fails on other inputs, and generates lower-case hexadecimal digits.

Numeric representations

chr :: Int -> Char #

The toEnum method restricted to the type Char.