[project @ 1998-01-30 16:57:33 by sof]
[ghc-hetmet.git] / ghc / lib / required / Numeric.lhs
index 2b63f56..4226863 100644 (file)
@@ -1,11 +1,12 @@
 %
-% (c) The AQUA Project, Glasgow University, 1997
+% (c) The AQUA Project, Glasgow University, 1997-98
 %
 \section[Numeric]{Numeric interface}
 
 Odds and ends, mostly functions for reading and showing
 \tr{RealFloat}-like kind of values.
 
+
 \begin{code}
 {-# OPTIONS -fno-implicit-prelude #-}
 module Numeric
@@ -17,7 +18,6 @@ module Numeric
         readInt,
 
         readDec, readOct, readHex,
-         showDec, showOct, showHex,
 
         showEFloat, 
         showFFloat, 
@@ -31,6 +31,7 @@ module Numeric
        ) where
 
 import PrelBase
+import PrelMaybe
 import ArrBase
 import PrelNum
 import PrelRead
@@ -38,9 +39,9 @@ import PrelRead
 \end{code}
 
 %*********************************************************
-%*                                                     *
-\subsection{Signatures}
-%*                                                     *
+%*                                                      *
+\subsection[Numeric-signatures]{Signatures}
+%*                                                      *
 %*********************************************************
 
 Interface on offer:
@@ -80,41 +81,12 @@ showInt n r
     if n' == 0 then r' else showInt n' r'
     }}
 
-showIntAtBase :: Integral a => a -> (a -> Char) -> a -> ShowS
-showIntAtBase base toChr n r
-  = case quotRem n base of { (n', d) ->
-    case toChr d        of { C# c# -> -- stricter than necessary
-    let
-       r' = C# c# : r
-    in
-    if n' == 0 then r' else showIntAtBase base toChr n' r'
-    }}
-
-showDec :: Integral a => a -> ShowS
-showDec n r = 
- showIntAtBase 10 
-               (\ d -> chr (ord_0 + fromIntegral d)) 
-              n r
-
-showHex :: Integral a => a -> ShowS
-showHex n r = 
- showString "0x" $
- showIntAtBase 16 (toChrHex) n r
- where  
-  toChrHex d = 
-   if d < 10 then
-      chr (ord_0   + fromIntegral d)
-   else
-      chr (ord 'a' + fromIntegral (d - 10))
-
-showOct :: Integral a => a -> ShowS
-showOct n r = 
- showString "0o" $
- showIntAtBase 8 (toChrOct) n r
- where toChrOct d = chr (ord_0   + fromIntegral d)
-
 \end{code}
 
+Controlling the format and precision of floats. The code that
+implements the formatting itself is in @PrelNum@ to avoid
+mutual module deps.
+
 \begin{code}
 showEFloat    :: (RealFloat a) => Maybe Int -> a -> ShowS
 showFFloat    :: (RealFloat a) => Maybe Int -> a -> ShowS
@@ -125,6 +97,3 @@ showFFloat d x =  showString (formatRealFloat FFFixed d x)
 showGFloat d x =  showString (formatRealFloat FFGeneric d x)
 
 \end{code}
-      
-  
-