-- |
-- Module : Numeric
-- Copyright : (c) The University of Glasgow 2002
--- License : BSD-style (see the file libraries/core/LICENSE)
+-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : libraries@haskell.org
-- Stability : provisional
-- Portability : portable
--
--- $Id: Numeric.hs,v 1.7 2002/04/24 16:31:37 simonmar Exp $
---
-- Odds and ends, mostly functions for reading and showing
-- RealFloat-like kind of values.
--
#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)
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
return (n,s)
--- *********************************************************
--- * *
--- \subsection{Showing}
--- * *
--- *********************************************************
-
-
+-- -----------------------------------------------------------------------------
+-- Showing
#ifdef __GLASGOW_HASKELL__
showInt :: Integral a => a -> ShowS