summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2013-08-22 11:18:25 +0900
committerAustin Seipp <aseipp@pobox.com>2013-08-22 16:22:24 -0500
commit6170f97e3d8c54953b7cf49297374566875f4397 (patch)
tree65afd0d2f7d3f85d3197bccc2642cf07c2899624
parentf4f5a174883385c5da3f6b1e11213b93ab7f829b (diff)
downloadhaskell-6170f97e3d8c54953b7cf49297374566875f4397.tar.gz
Fingerprint: Add Show instance for easier debugging
Signed-off-by: Austin Seipp <aseipp@pobox.com>
-rw-r--r--libraries/base/GHC/Fingerprint/Type.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/libraries/base/GHC/Fingerprint/Type.hs b/libraries/base/GHC/Fingerprint/Type.hs
index 91d7250d49..ee209db844 100644
--- a/libraries/base/GHC/Fingerprint/Type.hs
+++ b/libraries/base/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