[project @ 2001-08-04 06:19:54 by ken]
[ghc-hetmet.git] / ghc / lib / std / PrelRead.lhs
index 084a22f..f8a2636 100644 (file)
@@ -1,5 +1,5 @@
 % ------------------------------------------------------------------------------
-% $Id: PrelRead.lhs,v 1.17 2001/02/22 13:17:59 simonpj Exp $
+% $Id: PrelRead.lhs,v 1.20 2001/05/23 09:28:44 simonmar Exp $
 %
 % (c) The University of Glasgow, 1994-2000
 %
@@ -13,7 +13,7 @@ Instances of the Read class.
 
 module PrelRead where
 
-import PrelErr         ( error )
+import {-# SOURCE #-} PrelErr          ( error )
 import PrelEnum                ( Enum(..), maxBound )
 import PrelNum
 import PrelReal
@@ -22,10 +22,6 @@ import PrelList
 import PrelMaybe
 import PrelShow                -- isAlpha etc
 import PrelBase
-
--- needed for readIO and instance Read Buffermode
-import PrelIOBase ( IO, userError, BufferMode(..) )
-import PrelException ( ioError )
 \end{code}
 
 %*********************************************************
@@ -101,19 +97,6 @@ read s          =
     (x,str1) <- reads str
     ("","")  <- lex str1
     return x
-
-  -- raises an exception instead of an error
-readIO          :: Read a => String -> IO a
-readIO s        =  case (do { (x,t) <- reads s ; ("","") <- lex t ; return x }) of
-#ifndef NEW_READS_REP
-                       [x]    -> return x
-                       []     -> ioError (userError "Prelude.readIO: no parse")
-                       _      -> ioError (userError "Prelude.readIO: ambiguous parse")
-#else
-                        Just x -> return x
-                        Nothing  -> ioError (userError "Prelude.readIO: no parse")
-#endif
-
 \end{code}
 
 \begin{code}
@@ -520,26 +503,27 @@ include lexing common prefixes such as '0x' or '0o' etc.
                ReadS Int,
                ReadS Integer #-}
 readDec :: (Integral a) => ReadS a
-readDec = readInt 10 isDigit (\d -> ord d - ord_0)
+readDec = readInt 10 isDigit (\d -> ord d - ord '0')
 
 {-# SPECIALISE readOct :: 
                ReadS Int,
                ReadS Integer #-}
 readOct :: (Integral a) => ReadS a
-readOct = readInt 8 isOctDigit (\d -> ord d - ord_0)
+readOct = readInt 8 isOctDigit (\d -> ord d - ord '0')
 
 {-# SPECIALISE readHex :: 
                ReadS Int,
                ReadS Integer #-}
 readHex :: (Integral a) => ReadS a
 readHex = readInt 16 isHexDigit hex
-           where hex d = ord d - (if isDigit d then ord_0
+           where hex d = ord d - (if isDigit d then ord '0'
                                   else ord (if isUpper d then 'A' else 'a') - 10)
 
 readInt :: (Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
 readInt radix isDig digToInt s = do
     (ds,r) <- nonnull isDig s
-    return (foldl1 (\n d -> n * radix + d) (map (fromInteger . int2Integer . digToInt) ds), r)
+    return (foldl1 (\n d -> n * radix + d)
+                   (map (fromInteger . toInteger . digToInt) ds), r)
 
 {-# SPECIALISE readSigned ::
                ReadS Int     -> ReadS Int,
@@ -622,26 +606,3 @@ readRational__ top_s
 #endif
 
 \end{code}
-
-%*********************************************************
-%*                                                     *
-\subsection{Reading BufferMode}
-%*                                                     *
-%*********************************************************
-
-This instance decl is here rather than somewhere more appropriate in
-order that we can avoid both orphan-instance modules and recursive
-dependencies.
-
-\begin{code}
-instance Read BufferMode where
-    readsPrec _ = 
-      readParen False
-       (\r ->  let lr = lex r
-               in
-               [(NoBuffering, rest)       | ("NoBuffering", rest) <- lr] ++
-               [(LineBuffering,rest)      | ("LineBuffering",rest) <- lr] ++
-               [(BlockBuffering mb,rest2) | ("BlockBuffering",rest1) <- lr,
-                                            (mb, rest2) <- reads rest1])
-
-\end{code}