summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Word.hs
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-09-16 02:57:44 +0100
committerIan Lynagh <igloo@earth.li>2011-09-16 02:57:44 +0100
commit19c467e54c0228155b8706e8f07ccf1a2f4e4095 (patch)
treef12d75b7a11aa64f2a2780e97db7f2bcab1e6ddf /libraries/base/GHC/Word.hs
parent61cd1df21a681d12c2d3eaf69ec3bedc1521b1ce (diff)
downloadhaskell-19c467e54c0228155b8706e8f07ccf1a2f4e4095.tar.gz
Give Word a proper Show instance
It was going via Integer before
Diffstat (limited to 'libraries/base/GHC/Word.hs')
-rw-r--r--libraries/base/GHC/Word.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs
index 443f083960..6dd308abb4 100644
--- a/libraries/base/GHC/Word.hs
+++ b/libraries/base/GHC/Word.hs
@@ -50,7 +50,14 @@ import GHC.Float () -- for RealFrac methods
data Word = W# Word# deriving (Eq, Ord)
instance Show Word where
- showsPrec p x = showsPrec p (toInteger x)
+ showsPrec _ (W# w) = showWord w
+
+showWord :: Word# -> ShowS
+showWord w# cs
+ | w# `ltWord#` 10## = C# (chr# (ord# '0'# +# word2Int# w#)) : cs
+ | otherwise = case chr# (ord# '0'# +# word2Int# (w# `remWord#` 10##)) of
+ c# ->
+ showWord (w# `quotWord#` 10##) (C# c# : cs)
instance Num Word where
(W# x#) + (W# y#) = W# (x# `plusWord#` y#)