[commit: base] master: Give Word a proper Show instance (cbfdfd4)
Ian Lynagh
igloo at earth.li
Sat Sep 17 13:29:44 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/cbfdfd47ed8f709ccb4a010bf30cdcbe66396f55
>---------------------------------------------------------------
commit cbfdfd47ed8f709ccb4a010bf30cdcbe66396f55
Author: Ian Lynagh <igloo at earth.li>
Date: Fri Sep 16 02:57:44 2011 +0100
Give Word a proper Show instance
It was going via Integer before
>---------------------------------------------------------------
GHC/Word.hs | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/GHC/Word.hs b/GHC/Word.hs
index 443f083..6dd308a 100644
--- a/GHC/Word.hs
+++ b/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#)
More information about the Cvs-libraries
mailing list