[project @ 2002-06-06 16:01:37 by simonpj]
[ghc-base.git] / Numeric.hs
index 2fb214d..9f84fdb 100644 (file)
@@ -62,11 +62,8 @@ import Array
 #endif
 
 
--- *********************************************************
--- *                                                      *
--- \subsection{Reading}
--- *                                                      *
--- *********************************************************
+-- -----------------------------------------------------------------------------
+-- Reading
 
 readInt :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
 readInt base isDigit valDigit = readP_to_S (L.readIntP base isDigit valDigit)
@@ -81,10 +78,11 @@ readFloat = readP_to_S readFloatP
 
 readFloatP :: RealFrac a => ReadP a
 readFloatP =
-  do L.Number x <- L.lex
-     case L.numberToRational x of
-       Nothing -> pfail
-       Just y  -> return (fromRational y)
+  do tok <- L.lex
+     case tok of
+       L.Rat y  -> return (fromRational y)
+       L.Int i  -> return (fromInteger i)
+       other    -> pfail
 
 -- It's turgid to have readSigned work using list comprehensions,
 -- but it's specified as a ReadS to ReadS transformer
@@ -102,13 +100,8 @@ readSigned readPos = readParen False read'
                               return (n,s)
 
 
--- *********************************************************
--- *                                                      *
--- \subsection{Showing}
--- *                                                      *
--- *********************************************************
-
-
+-- -----------------------------------------------------------------------------
+-- Showing
 
 #ifdef __GLASGOW_HASKELL__
 showInt :: Integral a => a -> ShowS