X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FNumeric.lhs;h=f38e4268248306cd7cf28162273b501b9c979252;hb=192b2bc9a0e943438faff225b0f82a8d7804a733;hp=919e832ff1d0fb6e51f318396484a97aeba0e3d2;hpb=009527af27c8ee36a59db4d451e7c7a9896cb1da;p=ghc-hetmet.git diff --git a/ghc/lib/std/Numeric.lhs b/ghc/lib/std/Numeric.lhs index 919e832..f38e426 100644 --- a/ghc/lib/std/Numeric.lhs +++ b/ghc/lib/std/Numeric.lhs @@ -1,5 +1,5 @@ % -% (c) The AQUA Project, Glasgow University, 1997-98 +% (c) The AQUA Project, Glasgow University, 1997-99 % \section[Numeric]{Numeric interface} @@ -10,72 +10,45 @@ Odds and ends, mostly functions for reading and showing \begin{code} {-# OPTIONS -fno-implicit-prelude #-} module Numeric - ( - fromRat, - showSigned, - readSigned, - showInt, - readInt, - readDec, readOct, readHex, - - showEFloat, - showFFloat, - showGFloat, - showFloat, - readFloat, + ( fromRat -- :: (RealFloat a) => Rational -> a + , showSigned -- :: (Real a) => (a -> ShowS) -> Int -> a -> ShowS + , readSigned -- :: (Real a) => ReadS a -> ReadS a + , showInt -- :: Integral a => a -> ShowS + , readInt -- :: (Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a + + , readDec -- :: (Integral a) => ReadS a + , readOct -- :: (Integral a) => ReadS a + , readHex -- :: (Integral a) => ReadS a + + , showEFloat -- :: (RealFloat a) => Maybe Int -> a -> ShowS + , showFFloat -- :: (RealFloat a) => Maybe Int -> a -> ShowS + , showGFloat -- :: (RealFloat a) => Maybe Int -> a -> ShowS + , showFloat -- :: (RealFloat a) => a -> ShowS + , readFloat -- :: (RealFloat a) => ReadS a + - floatToDigits, - lexDigits + , floatToDigits -- :: (RealFloat a) => Integer -> a -> ([Int], Int) + , lexDigits -- :: ReadS String + -- Implementation checked wrt. Haskell 98 lib report, 1/99. ) where import PrelBase import PrelMaybe import PrelArr import PrelNum +import PrelNumExtra import PrelRead import PrelErr ( error ) \end{code} -%********************************************************* -%* * -\subsection[Numeric-signatures]{Signatures} -%* * -%********************************************************* - -Interface on offer: - -\begin{pseudocode} -fromRat :: (RealFloat a) => Rational -> a - -showSigned :: (Real a) => (a -> ShowS) -> Int -> a -> ShowS -readSigned :: (Real a) => ReadS a -> ReadS a - -showInt :: Integral a => a -> ShowS -readInt :: (Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a - -readDec :: (Integral a) => ReadS a -readOct :: (Integral a) => ReadS a -readHex :: (Integral a) => ReadS a - -showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS -showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS -showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS -showFloat :: (RealFloat a) => a -> ShowS - -readFloat :: (RealFloat a) => ReadS a - -floatToDigits :: (RealFloat a) => Integer -> a -> ([Int], Int) -lexDigits :: ReadS String -\end{pseudocode} - \begin{code} showInt :: Integral a => a -> ShowS -showInt n r - | n < 0 = error "Numeric.showInt: can't show negative numbers" - | otherwise = go n r +showInt i rs + | i < 0 = error "Numeric.showInt: can't show negative numbers" + | otherwise = go i rs where go n r = case quotRem n 10 of { (n', d) ->