[project @ 2001-12-14 15:26:14 by sewardj]
[ghc-hetmet.git] / ghc / lib / std / PrelRead.lhs
index 67a8194..2b060fc 100644 (file)
@@ -1,5 +1,5 @@
 % ------------------------------------------------------------------------------
-% $Id: PrelRead.lhs,v 1.19 2001/05/22 19:25:49 qrczak Exp $
+% $Id: PrelRead.lhs,v 1.22 2001/11/23 16:20:08 simonpj Exp $
 %
 % (c) The University of Glasgow, 1994-2000
 %
@@ -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}
 
 %*********************************************************
@@ -375,7 +371,7 @@ instance  (Integral a, Read a)  => Read (Ratio a)  where
                                (x,s)   <- reads r
                                ("%",t) <- lex s
                                (y,u)   <- reads t
-                               return (x%y,u))
+                               return (x % y,u))
 
 instance  (Read a) => Read [a]  where
     readsPrec _         = readList
@@ -556,23 +552,22 @@ point type to obtain the same results.
                    ReadS Double,
                    ReadS Float     #-} 
 readFloat :: (RealFloat a) => ReadS a
-readFloat r = do
-    (x,t) <- readRational r
-    return (fromRational x,t)
-
-readRational :: ReadS Rational -- NB: doesn't handle leading "-"
-
-readRational r =
-   (do 
-      (n,d,s) <- readFix r
-      (k,t)   <- readExp s
-      return ((n%1)*10^^(k-d), t )) ++
+readFloat r =
+   (do
+      (x,t) <- readRational r
+      return (fromRational x,t) ) ++
    (do
       ("NaN",t) <- lex r
       return (0/0,t) ) ++
    (do
       ("Infinity",t) <- lex r
       return (1/0,t) )
+
+readRational :: ReadS Rational -- NB: doesn't handle leading "-"
+readRational r = do 
+     (n,d,s) <- readFix r
+     (k,t)   <- readExp s
+     return ((n%1)*10^^(k-d), t)
  where
      readFix r = do
        (ds,s)  <- lexDecDigits r