Created
November 27, 2015 21:25
-
-
Save adamczykm/00136e67c96295e5e2b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import GHC.Show (intToDigit) | |
-- | Fast hex representation of Word8 | |
showHex :: Word8 -> ShowS | |
showHex n0 = showIt (1 :: Int) (quotRem n0 16) | |
where | |
showIt x (n,d) r = seq c $ -- stricter than necessary | |
case x of | |
0 -> r' | |
_ -> showIt (x-1) (quotRem n 16) r' | |
where | |
c = intToDigit (fromIntegral d) | |
r' = c : r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment