[project @ 1999-05-11 17:05:43 by keithw]
[ghc-hetmet.git] / ghc / lib / std / Char.lhs
1 %
2 % (c) The AQUA Project, Glasgow University, 1994-1999
3 %
4
5 \section[Char]{Module @Char@}
6
7 \begin{code}
8 {-# OPTIONS -fno-implicit-prelude #-}
9
10 module Char 
11     ( 
12       Char
13
14     , isAscii, isLatin1, isControl
15     , isPrint, isSpace,  isUpper
16     , isLower, isAlpha,  isDigit
17     , isOctDigit, isHexDigit, isAlphaNum  -- :: Char -> Bool
18
19     , toUpper, toLower  -- :: Char -> Char
20
21     , digitToInt        -- :: Char -> Int
22     , intToDigit        -- :: Int  -> Char
23
24     , ord               -- :: Char -> Int
25     , chr               -- :: Int  -> Char
26     , readLitChar       -- :: ReadS Char 
27     , showLitChar       -- :: Char -> ShowS
28     , lexLitChar        -- :: ReadS String
29
30     , String
31
32      -- Implementation checked wrt. Haskell 98 lib report, 1/99.
33     ) where
34
35 import PrelBase
36 import PrelRead (readLitChar, lexLitChar)
37 import {-# SOURCE #-} PrelErr   ( error )
38
39 \end{code}
40
41 \begin{code}
42 -- Digit conversion operations
43
44 digitToInt :: Char -> Int
45 digitToInt c
46  | isDigit c            =  fromEnum c - fromEnum '0'
47  | c >= 'a' && c <= 'f' =  fromEnum c - fromEnum 'a' + 10
48  | c >= 'A' && c <= 'F' =  fromEnum c - fromEnum 'A' + 10
49  | otherwise            =  error ("Char.digitToInt: not a digit " ++ show c) -- sigh
50
51
52 \end{code}