[project @ 2001-08-28 09:55:35 by simonmar]
authorsimonmar <unknown>
Tue, 28 Aug 2001 09:55:35 +0000 (09:55 +0000)
committersimonmar <unknown>
Tue, 28 Aug 2001 09:55:35 +0000 (09:55 +0000)
Fix (read "Infinity") and (read "NaN") for RealFloat types.

ghc/lib/std/PrelRead.lhs

index f8a2636..b91cb96 100644 (file)
@@ -1,5 +1,5 @@
 % ------------------------------------------------------------------------------
-% $Id: PrelRead.lhs,v 1.20 2001/05/23 09:28:44 simonmar Exp $
+% $Id: PrelRead.lhs,v 1.21 2001/08/28 09:55:35 simonmar Exp $
 %
 % (c) The University of Glasgow, 1994-2000
 %
@@ -552,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