[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / lib / std / Char.lhs
1 %
2 % (c) The AQUA Project, Glasgow University, 1994-1996
3 %
4
5 \section[Char]{Module @Char@}
6
7 \begin{code}
8 {-# OPTIONS -fno-implicit-prelude #-}
9
10 module Char 
11     ( 
12      isAscii, isLatin1, isControl, 
13      isPrint, isSpace,  isUpper, 
14      isLower, isAlpha,  isDigit,  
15      isOctDigit, isHexDigit, isAlphanum,  -- :: Char -> Bool
16
17      toUpper, toLower,  -- :: Char -> Char
18
19      digitToInt,        -- :: Char -> Int
20      intToDigit,        -- :: Int  -> Char
21
22      ord,               -- :: Char -> Int
23      chr,               -- :: Int  -> Char
24      readLitChar,       -- :: ReadS Char 
25      showLitChar        -- :: Char -> ShowS
26     ) where
27
28 import PrelBase
29 import PrelRead (readLitChar)
30 import {-# SOURCE #-} PrelErr   ( error )
31
32 \end{code}
33
34 \begin{code}
35 -- Digit conversion operations
36
37 digitToInt :: Char -> Int
38 digitToInt c
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
43
44
45 \end{code}