[commit: packages/base] master: Fingerprint: Add Show instance for easier debugging (e057b7f)
git at git.haskell.org
git at git.haskell.org
Thu Aug 22 23:25:55 CEST 2013
Repository : ssh://git@git.haskell.org/base
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/e057b7f23e4b4925bd409238282682cf5dda262d/base
>---------------------------------------------------------------
commit e057b7f23e4b4925bd409238282682cf5dda262d
Author: Niklas Hambüchen <mail at nh2.me>
Date: Thu Aug 22 11:18:25 2013 +0900
Fingerprint: Add Show instance for easier debugging
Signed-off-by: Austin Seipp <aseipp at pobox.com>
>---------------------------------------------------------------
e057b7f23e4b4925bd409238282682cf5dda262d
GHC/Fingerprint/Type.hs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/GHC/Fingerprint/Type.hs b/GHC/Fingerprint/Type.hs
index 91d7250..ee209db 100644
--- a/GHC/Fingerprint/Type.hs
+++ b/GHC/Fingerprint/Type.hs
@@ -12,10 +12,21 @@
module GHC.Fingerprint.Type (Fingerprint(..)) where
import GHC.Base
+import GHC.List (length, replicate)
+import GHC.Num
+import GHC.Show
import GHC.Word
+import Numeric (showHex)
-- Using 128-bit MD5 fingerprints for now.
data Fingerprint = Fingerprint {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64
deriving (Eq, Ord)
+instance Show Fingerprint where
+ show (Fingerprint w1 w2) = hex16 w1 ++ hex16 w2
+ where
+ -- | Formats a 64 bit number as 16 digits hex.
+ hex16 :: Word64 -> String
+ hex16 i = let hex = showHex i ""
+ in replicate (16 - length hex) '0' ++ hex
More information about the ghc-commits
mailing list