2 % (c) The AQUA Project, Glasgow University, 1994-1996
5 \section[Char]{Module @Char@}
8 {-# OPTIONS -fno-implicit-prelude #-}
12 isAscii, isLatin1, isControl,
13 isPrint, isSpace, isUpper,
14 isLower, isAlpha, isDigit,
15 isOctDigit, isHexDigit, isAlphanum, -- :: Char -> Bool
17 toUpper, toLower, -- :: Char -> Char
19 digitToInt, -- :: Char -> Int
20 intToDigit, -- :: Int -> Char
22 ord, -- :: Char -> Int
23 chr, -- :: Int -> Char
24 readLitChar, -- :: ReadS Char
25 showLitChar -- :: Char -> ShowS
29 import PrelRead (readLitChar)
30 import PrelErr ( error )
35 -- Digit conversion operations
37 digitToInt :: Char -> Int
39 | isDigit c = fromEnum c - fromEnum '0'
40 | c >= 'a' && c <= 'f' = fromEnum c - fromEnum 'a' + 10
41 | c >= 'A' && c <= 'F' = fromEnum c - fromEnum 'A' + 10
42 | otherwise = error "Char.digitToInt: not a digit" -- sigh