Add word8PaddedLowerHex

This commit is contained in:
Andrew Martin 2020-01-03 06:42:32 -05:00
parent ecde041d9d
commit d496f23fd8
3 changed files with 15 additions and 0 deletions

View file

@ -47,6 +47,7 @@ module Data.ByteArray.Builder.Bounded
, word16LowerHex
, word16UpperHex
-- ** 8-bit
, word8PaddedLowerHex
, word8PaddedUpperHex
, word8LowerHex
, ascii
@ -383,6 +384,12 @@ word8LowerHex (W8# w) = word8LowerHex# w
word8PaddedUpperHex :: Word8 -> Builder 2
word8PaddedUpperHex (W8# w) = word8PaddedUpperHex# w
-- | Requires exactly 2 bytes. Encodes a 8-bit unsigned integer as
-- hexadecimal, zero-padding the encoding to 2 digits. This uses
-- lowercase for the alphabetical digits.
word8PaddedLowerHex :: Word8 -> Builder 2
word8PaddedLowerHex (W8# w) = word8PaddedLowerHex# w
-- TODO: Is it actually worth unrolling this loop. I suspect that it
-- might not be. Benchmark this.
word64PaddedUpperHex# :: Word# -> Builder 16