HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulerio-0.1.25.0Haskell2010

RIO.Char.Partial

Unicode Char partial functions. Import as:

import qualified RIO.Char.Partial as C'
Contents
  1. Single digit characters
  2. Numeric representations
Synopsis
  • Packagerio-0.1.25.0
  • Exports3
  • LanguageHaskell2010
  • LicenceMIT
  • SourcePartial.hs

Single digit characters

valuedigitToInt :: 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').

Examples

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

Example1 expression
map digitToInt ['0'..'9'][0,1,2,3,4,5,6,7,8,9]

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

Example2 expressions
map digitToInt ['a'..'f'][10,11,12,13,14,15]map digitToInt ['A'..'F'][10,11,12,13,14,15]

Anything else throws an exception:

Example2 expressions
digitToInt 'G'*** Exception: Char.digitToInt: not a digit 'G'digitToInt '♥'*** Exception: Char.digitToInt: not a digit '\9829'
valueintToDigit :: 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