[add show instances for various numeric types, utilize unsigned arithmetic to avoid negation issues.
John Meacham <john@repetae.net>**20070607231311] addfile ./lib/base/Jhc/Inst/Show.hs
hunk ./lib/base/Jhc/Inst/Show.hs 1
+{-# OPTIONS_JHC -N #-}
+
+module Jhc.Inst.Show() where
+
+import Jhc.Show
+import Prelude.Text
+import Data.Int
+import Jhc.Basics
+import Data.Word
+import Jhc.Order
+import Jhc.Num
+import Numeric(showInt)
+
+-- we convert them to Word or WordMax so the showIntAtBase specialization can occur.
+
+instance Show Word where
+    showsPrec _ x = showInt x
+
+instance Show Word8 where
+    showsPrec _ x = showInt (fromIntegral x :: Word)
+
+instance Show Word16 where
+    showsPrec _ x = showInt (fromIntegral x :: Word)
+
+instance Show Word32 where
+    showsPrec _ x = showInt (fromIntegral x :: Word)
+
+instance Show Word64 where
+    showsPrec _ x = showInt (fromIntegral x :: WordMax)
+
+instance Show WordPtr where
+    showsPrec _ x = showInt (fromIntegral x :: WordMax)
+
+instance Show WordMax where
+    showsPrec _ x = showInt x
+
+instance Show Int where
+    showsPrec p x
+        | x < 0 = showParen (p > 6) (showChar '-' . showInt (fromIntegral $ negate x :: Word))
+        | otherwise = showInt (fromIntegral x :: Word)
+
+instance Show Integer where
+    showsPrec p x
+        | x < 0 = showParen (p > 6) (showChar '-' . showInt (fromIntegral $ negate x :: WordMax))
+        | otherwise = showInt (fromIntegral x :: WordMax)
+
+instance Show Int8 where
+    showsPrec p x = showsPrec p (fromIntegral x :: Int)
+instance Show Int16 where
+    showsPrec p x = showsPrec p (fromIntegral x :: Int)
+instance Show Int32 where
+    showsPrec p x = showsPrec p (fromIntegral x :: Int)
+instance Show Int64 where
+    showsPrec p x = showsPrec p (fromIntegral x :: Integer)
+instance Show IntPtr where
+    showsPrec p x = showsPrec p (fromIntegral x :: Integer)
+
+
hunk ./lib/base/Numeric.hs 10
+import Data.Word
hunk ./lib/base/Numeric.hs 104
-  | x < 0     = showParen (p > 6) (showChar '-' . showPos (-x))
+  | x < 0     = showParen (p > 6) (showChar '-' . showPos (negate x))
hunk ./lib/base/Numeric.hs 107
+{-# INLINE showInt #-}
+
hunk ./lib/base/Numeric.hs 115
-{-# SPECIALIZE showIntAtBase :: Int -> (Int -> Char) -> Int -> ShowS #-}
-{-# SPECIALIZE showIntAtBase :: Integer -> (Int -> Char) -> Integer -> ShowS #-}
+{-# SPECIALIZE showIntAtBase :: Word -> (Int -> Char) -> Word -> ShowS #-}
+{-# SPECIALIZE showIntAtBase :: WordMax -> (Int -> Char) -> WordMax -> ShowS #-}
+
hunk ./lib/base/Prelude.hs 53
+import Jhc.Inst.Show
hunk ./lib/base/Prelude/Text.hs 105
-instance  Show Int  where
-    showsPrec n = showsPrec n . toInteger
-        -- Converting to Integer avoids
-        -- possible difficulty with minInt
hunk ./lib/base/Prelude/Text.hs 111
-instance  Show Integer  where
-    showsPrec           = showSigned showInt
hunk ./lib/base/Prelude/Text.hs 167
-    {-
-instance Show a => Show (Maybe a) where
-    showsPrec _p Nothing s = showString "Nothing" s
-    showsPrec p (Just x) s
-                          = (showParen (p > 10) $
-    			     showString "Just " .
-			     showsPrec 11 x) s
-
-instance (Show a, Show b) => Show (Either a b) where
-    showsPrec p e s =
-       (showParen (p > 10) $
-        case e of
-         Left  a -> showString "Left "  . showsPrec 11 a
-	 Right b -> showString "Right " . showsPrec 11 b)
-       s
-    -}
-
--- Tuples
-{-
-
-instance  (Show a, Show b) => Show (a,b)  where
-    showsPrec p (x,y) = showChar '(' . shows x . showChar ',' .
-                                       shows y . showChar ')'
-
-instance  (Read a, Read b) => Read (a,b)  where
-    readsPrec p       = readParen False
-                            (\r -> [((x,y), w) | ("(",s) <- lex r,
-                                                 (x,t)   <- reads s,
-                                                 (",",u) <- lex t,
-                                                 (y,v)   <- reads u,
-                                                 (")",w) <- lex v ] )
-
-instance  (Show a, Show b) => Show (a,b)  where
-    showsPrec _ (x,y) s = (showChar '(' . shows x . showChar ',' .
-                                          shows y . showChar ')')
-			  s
-
-instance (Show a, Show b, Show c) => Show (a, b, c) where
-    showsPrec _ (x,y,z) s = (showChar '(' . shows x . showChar ',' .
-					    shows y . showChar ',' .
-					    shows z . showChar ')')
-			    s
-
-instance (Show a, Show b, Show c, Show d) => Show (a, b, c, d) where
-    showsPrec _ (w,x,y,z) s = (showChar '(' . shows w . showChar ',' .
-					      shows x . showChar ',' .
-					      shows y . showChar ',' .
-					      shows z . showChar ')')
-			      s
-
-instance (Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) where
-    showsPrec _ (v,w,x,y,z) s = (showChar '(' . shows v . showChar ',' .
-					     	shows w . showChar ',' .
-					     	shows x . showChar ',' .
-					     	shows y . showChar ',' .
-					     	shows z . showChar ')')
-				s
--- Other tuples have similar Read and Show instances
-
--}
-