put 'unsafeCoerce' in a standard location
[haskell-directory.git] / GHC / Show.lhs
index 8673357..85d4c7d 100644 (file)
@@ -397,12 +397,13 @@ showSignedInt (I# p) (I# n) r
 
 itos :: Int# -> String -> String
 itos n# cs
-    | n# <# 0# = let
-        n'# = negateInt# n#
-        in if n'# <# 0# -- minInt?
-            then '-' : itos' (negateInt# (n'# `quotInt#` 10#))
-                             (itos' (negateInt# (n'# `remInt#` 10#)) cs)
-            else '-' : itos' n'# cs
+    | n# <# 0# =
+       let I# minInt# = minInt in
+       if n# ==# minInt#
+               -- negateInt# minInt overflows, so we can't do that:
+          then '-' : itos' (negateInt# (n# `quotInt#` 10#))
+                             (itos' (negateInt# (n# `remInt#` 10#)) cs)
+          else '-' : itos' (negateInt# n#) cs
     | otherwise = itos' n# cs
     where
     itos' :: Int# -> String -> String
@@ -411,3 +412,32 @@ itos n# cs
         | otherwise = case chr# (ord# '0'# +# (n# `remInt#` 10#)) of { c# ->
                      itos' (n# `quotInt#` 10#) (C# c# : cs) }
 \end{code}
+
+%*********************************************************
+%*                                                     *
+\subsection{Other instances}
+%*                                                     *
+%*********************************************************
+
+\begin{code}
+instance Show Unknown where
+ show _ = "This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type"
+ showList _ = ("This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type" ++)
+
+instance Show (Unknown1 a) where
+ show _ = "This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type"
+ showList _ = ("This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type" ++)
+
+instance Show (Unknown2 a b) where
+ show _ = "This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type"
+ showList _ = ("This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type" ++)
+
+instance Show (Unknown3 a b c) where
+ show _ = "This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type"
+ showList _ = ("This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type" ++)
+
+instance Show (Unknown4 a b c d) where
+ show _ = "This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type"
+ showList _ = ("This is an untyped, unevaluated computation. You can use seq to force its evaluation and then :print to recover its type" ++)
+
+\end{code}
\ No newline at end of file