base32 0.2.2.0 → 0.4
raw patch · 24 files changed
Files
- CHANGELOG.md +17/−0
- README.md +2/−2
- Setup.hs +0/−2
- base32.cabal +15/−15
- src/Data/ByteString/Base32.hs +4/−4
- src/Data/ByteString/Base32/Hex.hs +4/−4
- src/Data/ByteString/Base32/Internal.hs +6/−10
- src/Data/ByteString/Base32/Internal/Head.hs +10/−10
- src/Data/ByteString/Base32/Internal/Loop.hs +18/−22
- src/Data/ByteString/Base32/Internal/Tables.hs +2/−3
- src/Data/ByteString/Base32/Internal/Tail.hs +22/−26
- src/Data/ByteString/Lazy/Base32.hs +1/−2
- src/Data/ByteString/Lazy/Base32/Hex.hs +1/−2
- src/Data/ByteString/Short/Base32.hs +1/−1
- src/Data/ByteString/Short/Base32/Hex.hs +1/−1
- src/Data/Text/Encoding/Base32.hs +7/−7
- src/Data/Text/Encoding/Base32/Error.hs +1/−1
- src/Data/Text/Encoding/Base32/Hex.hs +7/−7
- src/Data/Text/Lazy/Encoding/Base32.hs +8/−8
- src/Data/Text/Lazy/Encoding/Base32/Hex.hs +8/−8
- src/Data/Text/Short/Encoding/Base32.hs +4/−4
- src/Data/Text/Short/Encoding/Base32/Hex.hs +4/−4
- test/Internal.hs +5/−5
- test/Main.hs +16/−16
CHANGELOG.md view
@@ -1,5 +1,22 @@ # Revision history for base32 +## 0.4++* Support for GHC 9.8+* Drop support for GHC <9.x+* Bump `bytestring` lower bound to 0.11 (thanks @vlix!)++## 0.3.1.0++* Small bug fix+* Doc updates++## 0.3++* Bump lower bounds for `bytestring` and `text` to latest significant major/major version+* Update CI for 8.10.x thru 9.6 coverage+* Correct the update the latin1 decode default for text modules to `utf8` (which is now pure for `text-2.0`).+ ## 0.2.2.0 * Add support for GHC 9.2.x
README.md view
@@ -1,6 +1,6 @@ # Base32 -[](https://travis-ci.com/emilypi/base32)+ [](https://hackage.haskell.org/package/base32) Padded and unpadded base32 and base32hex encoding and decoding for `Text` and `ByteString` values.@@ -24,4 +24,4 @@ - Optics for handling more complex structures with Base32 representations via the `base32-lens` package - Checks for both validity and correctness of Base32 and Base32hex encodings -There are no dependencies aside from those bundled with GHC, `text-short`, and the `ghc-byteorder` re-export.+There are no dependencies aside from those bundled with GHC, `text-short`.
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
base32.cabal view
@@ -1,6 +1,6 @@-cabal-version: 2.0+cabal-version: 3.0 name: base32-version: 0.2.2.0+version: 0.4 synopsis: Fast RFC 4648-compliant Base32 encoding description: RFC 4648-compliant Base32 encodings and decodings.@@ -8,11 +8,11 @@ homepage: https://github.com/emilypi/base32 bug-reports: https://github.com/emilypi/base32/issues-license: BSD3+license: BSD-3-Clause license-file: LICENSE author: Emily Pillmore maintainer: emilypi@cohomolo.gy-copyright: (c) 2020-2022 Emily Pillmore+copyright: (c) 2020-2023 Emily Pillmore category: Data build-type: Simple extra-source-files:@@ -20,7 +20,7 @@ README.md tested-with:- GHC ==8.10.7 || ==9.0.2 || ==9.2.2+ GHC ==9.0.2 || ==9.2.8 || ==9.4.7 || ==9.6.3 || ==9.8.1 source-repository head type: git@@ -51,10 +51,10 @@ Data.ByteString.Base32.Internal.Utils build-depends:- base >=4.14 && <4.17- , bytestring >=0.10 && <0.12- , deepseq ^>=1.4- , text ^>=1.2+ base >=4.15 && <4.20+ , bytestring ^>=0.11+ , deepseq >=1.4.4.0 && <1.6+ , text >=2.0 && <2.2 , text-short ^>=0.1 hs-source-dirs: src@@ -68,16 +68,16 @@ other-modules: Internal main-is: Main.hs build-depends:- base >=4.14 && <4.17+ base >=4.15 && <4.20 , base32- , bytestring+ , bytestring ^>=0.11 , memory , QuickCheck , random-bytestring , tasty , tasty-hunit , tasty-quickcheck- , text+ , text >=2.0 , text-short benchmark bench@@ -86,11 +86,11 @@ hs-source-dirs: benchmarks main-is: Base32Bench.hs build-depends:- base >=4.14 && <4.17+ base >=4.15 && <4.20 , base32- , bytestring+ , bytestring ^>=0.11 , criterion , deepseq , memory , random-bytestring- , text+ , text >=2.0
src/Data/ByteString/Base32.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.ByteString.Base32--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -89,7 +89,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32 :: ByteString -> Either Text ByteString-decodeBase32 bs@(PS _ _ !l)+decodeBase32 bs@(BS _ !l) | l == 0 = Right bs | r == 0 = unsafeDupablePerformIO $ decodeBase32_ stdDecodeTable bs | r == 2 = unsafeDupablePerformIO $ decodeBase32_ stdDecodeTable (BS.append bs "======")@@ -140,7 +140,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32Unpadded :: ByteString -> Either Text ByteString-decodeBase32Unpadded bs@(PS _ _ !l)+decodeBase32Unpadded bs@(BS _ !l) | l == 0 = Right bs | r == 0 = validateLastNPads 1 bs $ decodeBase32_ stdDecodeTable bs | r == 2 = unsafeDupablePerformIO $ decodeBase32_ stdDecodeTable (BS.append bs "======")@@ -165,7 +165,7 @@ -- Left "Base32-encoded bytestring requires padding" -- decodeBase32Padded :: ByteString -> Either Text ByteString-decodeBase32Padded bs@(PS _ _ !l)+decodeBase32Padded bs@(BS _ !l) | l == 0 = Right bs | r == 1 = Left "Base32-encoded bytestring has invalid size" | r == 3 = Left "Base32-encoded bytestring has invalid size"
src/Data/ByteString/Base32/Hex.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.ByteString.Base32.Hex--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -89,7 +89,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32 :: ByteString -> Either Text ByteString-decodeBase32 bs@(PS _ _ !l)+decodeBase32 bs@(BS _ !l) | l == 0 = Right bs | r == 0 = unsafeDupablePerformIO $ decodeBase32_ hexDecodeTable bs | r == 2 = unsafeDupablePerformIO $ decodeBase32_ hexDecodeTable (BS.append bs "======")@@ -140,7 +140,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32Unpadded :: ByteString -> Either Text ByteString-decodeBase32Unpadded bs@(PS _ _ !l)+decodeBase32Unpadded bs@(BS _ !l) | l == 0 = Right bs | r == 0 = validateLastNPads 1 bs $ decodeBase32_ hexDecodeTable bs | r == 2 = unsafeDupablePerformIO $ decodeBase32_ hexDecodeTable (BS.append bs "======")@@ -165,7 +165,7 @@ -- Left "Base32-encoded bytestring requires padding" -- decodeBase32Padded :: ByteString -> Either Text ByteString-decodeBase32Padded bs@(PS _ _ !l)+decodeBase32Padded bs@(BS _ !l) | l == 0 = Right bs | r == 1 = Left "Base32-encoded bytestring has invalid size" | r == 3 = Left "Base32-encoded bytestring has invalid size"
src/Data/ByteString/Base32/Internal.hs view
@@ -1,8 +1,5 @@ {-# LANGUAGE BangPatterns #-}-{-# LANGUAGE CPP #-}-{-# LANGUAGE MagicHash #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeApplications #-} -- | -- Module : Data.ByteString.Base32.Internal -- Copyright : (c) 2020 Emily Pillmore@@ -43,7 +40,7 @@ -- | Validate a base32-encoded bytestring against some alphabet. -- validateBase32 :: ByteString -> ByteString -> Bool-validateBase32 !alphabet bs@(PS _ _ l)+validateBase32 !alphabet bs@(BS _ l) | l == 0 = True | r == 0 = f bs | r == 2 = f (BS.append bs "======")@@ -54,8 +51,8 @@ where r = l `rem` 8 - f (PS fp o l') = accursedUnutterablePerformIO $ withForeignPtr fp $ \p ->- go (plusPtr p o) (plusPtr p (l' + o))+ f (BS fp l') = accursedUnutterablePerformIO $ withForeignPtr fp $ \p ->+ go p (plusPtr p l') go !p !end | p == end = return True@@ -105,13 +102,12 @@ -> ByteString -> IO (Either Text ByteString) -> Either Text ByteString-validateLastNPads !n (PS !fp !o !l) io+validateLastNPads !n (BS !fp !l) io | not valid = Left "Base32-encoded bytestring has invalid padding" | otherwise = unsafeDupablePerformIO io where- !lo = l + o valid = accursedUnutterablePerformIO $ withForeignPtr fp $ \p -> do- let end = plusPtr p lo+ let end = plusPtr p l let go :: Ptr Word8 -> IO Bool go !q@@ -120,5 +116,5 @@ a <- peek q if a == 0x3d then return False else go (plusPtr q 1) - go (plusPtr p (lo - n))+ go (plusPtr p (l - n)) {-# INLINE validateLastNPads #-}
src/Data/ByteString/Base32/Internal/Head.hs view
@@ -1,6 +1,6 @@-{-# LANGUAGE TypeApplications #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE MagicHash #-}+{-# LANGUAGE TypeApplications #-} module Data.ByteString.Base32.Internal.Head ( encodeBase32_ , encodeBase32NoPad_@@ -30,13 +30,13 @@ -- executes the inner encoding loop against that data. -- encodeBase32_ :: Addr# -> ByteString -> ByteString-encodeBase32_ !lut (PS !sfp !o !l) = unsafeDupablePerformIO $ do+encodeBase32_ !lut (BS !sfp !l) = unsafeDupablePerformIO $ do dfp <- mallocPlainForeignPtrBytes dlen withForeignPtr dfp $ \dptr -> withForeignPtr sfp $ \sptr -> do- let !end = plusPtr sptr (l + o)+ let !end = plusPtr sptr l innerLoop lut- (castPtr dptr) (plusPtr sptr o)+ (castPtr dptr) sptr end (loopTail lut dfp dptr end) where !dlen = ceiling (fromIntegral @_ @Double l / 5) * 8@@ -48,13 +48,13 @@ -- executes the inner encoding loop against that data. -- encodeBase32NoPad_ :: Addr# -> ByteString -> ByteString-encodeBase32NoPad_ !lut (PS !sfp !o !l) = unsafeDupablePerformIO $ do+encodeBase32NoPad_ !lut (BS !sfp !l) = unsafeDupablePerformIO $ do !dfp <- mallocPlainForeignPtrBytes dlen withForeignPtr dfp $ \dptr -> withForeignPtr sfp $ \sptr -> do- let !end = plusPtr sptr (l + o)+ let !end = plusPtr sptr l innerLoop lut- (castPtr dptr) (plusPtr sptr o)+ (castPtr dptr) sptr end (loopTailNoPad lut dfp dptr end) where !dlen = ceiling (fromIntegral @_ @Double l / 5) * 8@@ -66,11 +66,11 @@ -- and executes the inner decoding loop against that data. -- decodeBase32_ :: Ptr Word8 -> ByteString -> IO (Either Text ByteString)-decodeBase32_ (Ptr !dtable) (PS !sfp !soff !slen) =+decodeBase32_ (Ptr !dtable) (BS !sfp !slen) = withForeignPtr sfp $ \sptr -> do dfp <- mallocPlainForeignPtrBytes dlen withForeignPtr dfp $ \dptr -> do- let !end = plusPtr sptr (soff + slen)- decodeLoop dtable dfp dptr (plusPtr sptr soff) end+ let !end = plusPtr sptr slen+ decodeLoop dtable dfp dptr sptr end where !dlen = ceiling (fromIntegral @_ @Double slen / 1.6)
src/Data/ByteString/Base32/Internal/Loop.hs view
@@ -1,7 +1,5 @@ {-# LANGUAGE BangPatterns #-}-{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-}-{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeApplications #-} module Data.ByteString.Base32.Internal.Loop ( innerLoop@@ -72,43 +70,41 @@ :: Addr# -> ForeignPtr Word8 -> Ptr Word8- -> Ptr Word64 -> Ptr Word8+ -> Ptr Word8 -> IO (Either Text ByteString) decodeLoop !lut !dfp !dptr !sptr !end = go dptr sptr where lix a = w64 (aix (fromIntegral a) lut) - err :: Ptr Word64 -> IO (Either Text ByteString)+ err :: Ptr Word8 -> IO (Either Text ByteString) err p = return . Left . T.pack $ "invalid character at offset: " ++ show (p `minusPtr` sptr) - padErr :: Ptr Word64 -> IO (Either Text ByteString)+ padErr :: Ptr Word8 -> IO (Either Text ByteString) padErr p = return . Left . T.pack $ "invalid padding at offset: " ++ show (p `minusPtr` sptr) look :: Ptr Word8 -> IO Word64- look !p = lix . w64 <$> peek @Word8 p+ look !p = lix <$> peek @Word8 p go !dst !src | plusPtr src 8 >= end = do - let src' = castPtr src-- a <- look src'- b <- look (plusPtr src' 1)- c <- look (plusPtr src' 2)- d <- look (plusPtr src' 3)- e <- look (plusPtr src' 4)- f <- look (plusPtr src' 5)- g <- look (plusPtr src' 6)- h <- look (plusPtr src' 7)+ a <- look src+ b <- look (plusPtr src 1)+ c <- look (plusPtr src 2)+ d <- look (plusPtr src 3)+ e <- look (plusPtr src 4)+ f <- look (plusPtr src 5)+ g <- look (plusPtr src 6)+ h <- look (plusPtr src 7) finalChunk dst src a b c d e f g h | otherwise = do- !t <- peekWord64BE src+ !t <- peekWord64BE (castPtr src) let a = lix (unsafeShiftR t 56) b = lix (unsafeShiftR t 48)@@ -149,18 +145,18 @@ case (c,d,e,f,g,h) of (0x63,0x63,0x63,0x63,0x63,0x63) ->- return (Right (PS dfp 0 (1 + minusPtr dst dptr)))+ return (Right (BS dfp (1 + minusPtr dst dptr))) (0x63,_,_,_,_,_) -> padErr (plusPtr src 3) (_,0x63,0x63,0x63,0x63,0x63) -> padErr (plusPtr src 3) (_,0x63,_,_,_,_) -> padErr (plusPtr src 4) (_,_,0x63,0x63,0x63,0x63) -> do poke @Word8 (plusPtr dst 2) o3- return (Right (PS dfp 0 (2 + minusPtr dst dptr)))+ return (Right (BS dfp (2 + minusPtr dst dptr))) (_,_,0x63,_,_,_) -> padErr (plusPtr src 5) (_,_,_,0x63,0x63,0x63) -> do poke @Word8 (plusPtr dst 2) o3 poke @Word8 (plusPtr dst 3) o4- return (Right (PS dfp 0 (3 + minusPtr dst dptr)))+ return (Right (BS dfp (3 + minusPtr dst dptr))) (_,_,_,0x63,_,_) -> padErr (plusPtr src 6) (_,_,_,_,0x63,0x63) -> padErr (plusPtr src 6) (_,_,_,_,0x63,_) -> padErr (plusPtr src 7)@@ -168,12 +164,12 @@ poke @Word8 (plusPtr dst 2) o3 poke @Word8 (plusPtr dst 3) o4 poke @Word8 (plusPtr dst 4) o5- return (Right (PS dfp 0 (4 + minusPtr dst dptr)))+ return (Right (BS dfp (4 + minusPtr dst dptr))) (_,_,_,_,_,_) -> do poke @Word8 (plusPtr dst 2) o3 poke @Word8 (plusPtr dst 3) o4 poke @Word8 (plusPtr dst 4) o5- return (Right (PS dfp 0 (5 + minusPtr dst dptr)))+ return (Right (BS dfp (5 + minusPtr dst dptr))) decodeChunk !dst !src !a !b !c !d !e !f !g !h | a == 0x63 = padErr src
src/Data/ByteString/Base32/Internal/Tables.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE MagicHash #-} {-# LANGUAGE TypeApplications #-} module Data.ByteString.Base32.Internal.Tables ( stdDecodeTable@@ -6,9 +5,9 @@ ) where -import Data.ByteString.Base32.Internal.Utils+import Data.ByteString.Base32.Internal.Utils (writeNPlainPtrBytes) -import GHC.Word+import GHC.Word (Word8) import GHC.Ptr (Ptr)
src/Data/ByteString/Base32/Internal/Tail.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE BangPatterns #-}-{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-}-{-# LANGUAGE MultiWayIf #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeApplications #-} module Data.ByteString.Base32.Internal.Tail ( loopTail , loopTailNoPad@@ -33,7 +29,7 @@ -> Ptr Word8 -> IO ByteString loopTail !lut !dfp !dptr !end !dst !src- | src == end = return (PS dfp 0 (minusPtr dst dptr))+ | src == end = return (BS dfp (minusPtr dst dptr)) | plusPtr src 1 == end = do -- 2 6 !a <- peek src @@ -44,13 +40,13 @@ poke (plusPtr dst 1) u padN (plusPtr dst 2) 6 - return (PS dfp 0 (8 + minusPtr dst dptr))+ return (BS dfp (8 + minusPtr dst dptr)) | plusPtr src 2 == end = do -- 4 4 !a <- peek src !b <- peek (plusPtr src 1) let !t = look (unsafeShiftR (a .&. 0xf8) 3)- !u = look ((unsafeShiftL (a .&. 0x07) 2) .|. (unsafeShiftR (b .&. 0xc0) 6))+ !u = look (unsafeShiftL (a .&. 0x07) 2 .|. unsafeShiftR (b .&. 0xc0) 6) !v = look (unsafeShiftR (b .&. 0x3e) 1) !w = look (unsafeShiftL (b .&. 0x01) 4) @@ -60,16 +56,16 @@ poke (plusPtr dst 3) w padN (plusPtr dst 4) 4 - return (PS dfp 0 (8 + minusPtr dst dptr))+ return (BS dfp (8 + minusPtr dst dptr)) | plusPtr src 3 == end = do -- 5 3 !a <- peek src !b <- peek (plusPtr src 1) !c <- peek (plusPtr src 2) let !t = look (unsafeShiftR (a .&. 0xf8) 3)- !u = look ((unsafeShiftL (a .&. 0x07) 2) .|. (unsafeShiftR (b .&. 0xc0) 6))+ !u = look (unsafeShiftL (a .&. 0x07) 2 .|. unsafeShiftR (b .&. 0xc0) 6) !v = look (unsafeShiftR (b .&. 0x3e) 1)- !w = look ((unsafeShiftL (b .&. 0x01) 4) .|. (unsafeShiftR (c .&. 0xf0) 4))+ !w = look (unsafeShiftL (b .&. 0x01) 4 .|. unsafeShiftR (c .&. 0xf0) 4) !x = look (unsafeShiftL (c .&. 0x0f) 1) poke dst t@@ -78,7 +74,7 @@ poke (plusPtr dst 3) w poke (plusPtr dst 4) x padN (plusPtr dst 5) 3- return (PS dfp 0 (8 + minusPtr dst dptr))+ return (BS dfp (8 + minusPtr dst dptr)) | otherwise = do -- 7 1 !a <- peek src@@ -87,10 +83,10 @@ !d <- peek (plusPtr src 3) let !t = look (unsafeShiftR (a .&. 0xf8) 3)- !u = look ((unsafeShiftL (a .&. 0x07) 2) .|. (unsafeShiftR (b .&. 0xc0) 6))+ !u = look (unsafeShiftL (a .&. 0x07) 2 .|. unsafeShiftR (b .&. 0xc0) 6) !v = look (unsafeShiftR (b .&. 0x3e) 1)- !w = look ((unsafeShiftL (b .&. 0x01) 4) .|. (unsafeShiftR (c .&. 0xf0) 4))- !x = look ((unsafeShiftL (c .&. 0x0f) 1) .|. (unsafeShiftR (d .&. 0x80) 7))+ !w = look (unsafeShiftL (b .&. 0x01) 4 .|. unsafeShiftR (c .&. 0xf0) 4)+ !x = look (unsafeShiftL (c .&. 0x0f) 1 .|. unsafeShiftR (d .&. 0x80) 7) !y = look (unsafeShiftR (d .&. 0x7c) 2) !z = look (unsafeShiftL (d .&. 0x03) 3) @@ -102,7 +98,7 @@ poke (plusPtr dst 5) y poke (plusPtr dst 6) z padN (plusPtr dst 7) 1- return (PS dfp 0 (8 + minusPtr dst dptr))+ return (BS dfp (8 + minusPtr dst dptr)) where look !n = aix n lut @@ -122,7 +118,7 @@ -> Ptr Word8 -> IO ByteString loopTailNoPad !lut !dfp !dptr !end !dst !src- | src == end = return (PS dfp 0 (minusPtr dst dptr))+ | src == end = return (BS dfp (minusPtr dst dptr)) | plusPtr src 1 == end = do -- 2 6 !a <- peek src @@ -132,14 +128,14 @@ poke dst t poke (plusPtr dst 1) u - return (PS dfp 0 (2 + minusPtr dst dptr))+ return (BS dfp (2 + minusPtr dst dptr)) | plusPtr src 2 == end = do -- 4 4 !a <- peek src !b <- peek (plusPtr src 1) let !t = look (unsafeShiftR (a .&. 0xf8) 3)- !u = look ((unsafeShiftL (a .&. 0x07) 2) .|. (unsafeShiftR (b .&. 0xc0) 6))+ !u = look (unsafeShiftL (a .&. 0x07) 2 .|. unsafeShiftR (b .&. 0xc0) 6) !v = look (unsafeShiftR (b .&. 0x3e) 1) !w = look (unsafeShiftL (b .&. 0x01) 4) @@ -148,7 +144,7 @@ poke (plusPtr dst 2) v poke (plusPtr dst 3) w - return (PS dfp 0 (4 + minusPtr dst dptr))+ return (BS dfp (4 + minusPtr dst dptr)) | plusPtr src 3 == end = do -- 5 3 !a <- peek src@@ -156,9 +152,9 @@ !c <- peek (plusPtr src 2) let !t = look (unsafeShiftR (a .&. 0xf8) 3)- !u = look ((unsafeShiftL (a .&. 0x07) 2) .|. (unsafeShiftR (b .&. 0xc0) 6))+ !u = look (unsafeShiftL (a .&. 0x07) 2 .|. unsafeShiftR (b .&. 0xc0) 6) !v = look (unsafeShiftR (b .&. 0x3e) 1)- !w = look ((unsafeShiftL (b .&. 0x01) 4) .|. (unsafeShiftR (c .&. 0xf0) 4))+ !w = look (unsafeShiftL (b .&. 0x01) 4 .|. unsafeShiftR (c .&. 0xf0) 4) !x = look (unsafeShiftL (c .&. 0x0f) 1) poke dst t@@ -166,7 +162,7 @@ poke (plusPtr dst 2) v poke (plusPtr dst 3) w poke (plusPtr dst 4) x- return (PS dfp 0 (5 + minusPtr dst dptr))+ return (BS dfp (5 + minusPtr dst dptr)) | otherwise = do -- 7 1 !a <- peek src@@ -175,10 +171,10 @@ !d <- peek (plusPtr src 3) let !t = look (unsafeShiftR (a .&. 0xf8) 3)- !u = look ((unsafeShiftL (a .&. 0x07) 2) .|. (unsafeShiftR (b .&. 0xc0) 6))+ !u = look (unsafeShiftL (a .&. 0x07) 2 .|. unsafeShiftR (b .&. 0xc0) 6) !v = look (unsafeShiftR (b .&. 0x3e) 1)- !w = look ((unsafeShiftL (b .&. 0x01) 4) .|. (unsafeShiftR (c .&. 0xf0) 4))- !x = look ((unsafeShiftL (c .&. 0x0f) 1) .|. (unsafeShiftR (d .&. 0x80) 7))+ !w = look (unsafeShiftL (b .&. 0x01) 4 .|. unsafeShiftR (c .&. 0xf0) 4)+ !x = look (unsafeShiftL (c .&. 0x0f) 1 .|. unsafeShiftR (d .&. 0x80) 7) !y = look (unsafeShiftR (d .&. 0x7c) 2) !z = look (unsafeShiftL (d .&. 0x03) 3) @@ -189,7 +185,7 @@ poke (plusPtr dst 4) x poke (plusPtr dst 5) y poke (plusPtr dst 6) z- return (PS dfp 0 (7 + minusPtr dst dptr))+ return (BS dfp (7 + minusPtr dst dptr)) where look !i = aix i lut {-# INLINE loopTailNoPad #-}
src/Data/ByteString/Lazy/Base32.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE BangPatterns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.ByteString.Lazy.Base32--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>
src/Data/ByteString/Lazy/Base32/Hex.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE BangPatterns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.ByteString.Lazy.Base32.Hex--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>
src/Data/ByteString/Short/Base32.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.ByteString.Short.Base32--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>
src/Data/ByteString/Short/Base32/Hex.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.ByteString.Short.Base32.Hex--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>
src/Data/Text/Encoding/Base32.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Safe #-} -- | -- Module : Data.Text.Encoding.Base32--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -54,7 +54,7 @@ -- 4 for safe decoding as base32 encodings are optionally padded. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32With` -- and pass in a custom decode function.@@ -73,7 +73,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32 :: Text -> Either Text Text-decodeBase32 = fmap T.decodeLatin1+decodeBase32 = fmap T.decodeUtf8 . B32.decodeBase32 . T.encodeUtf8 {-# INLINE decodeBase32 #-}@@ -118,7 +118,7 @@ -- | Decode an unpadded Base32 encoded 'Text' value. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32WUnpaddedWith` -- and pass in a custom decode function.@@ -134,7 +134,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32Unpadded :: Text -> Either Text Text-decodeBase32Unpadded = fmap T.decodeLatin1+decodeBase32Unpadded = fmap T.decodeUtf8 . B32.decodeBase32Unpadded . T.encodeUtf8 {-# INLINE decodeBase32Unpadded #-}@@ -167,7 +167,7 @@ -- | Decode an padded Base32 encoded 'Text' value -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32PaddedWith` -- and pass in a custom decode function.@@ -183,7 +183,7 @@ -- Left "Base32-encoded bytestring requires padding" -- decodeBase32Padded :: Text -> Either Text Text-decodeBase32Padded = fmap T.decodeLatin1+decodeBase32Padded = fmap T.decodeUtf8 . B32.decodeBase32Padded . T.encodeUtf8 {-# INLINE decodeBase32Padded #-}
src/Data/Text/Encoding/Base32/Error.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE Safe #-} -- | -- Module : Data.Text.Encoding.Base32.Error--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>
src/Data/Text/Encoding/Base32/Hex.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Safe #-} -- | -- Module : Data.Text.Encoding.Base32.Hex--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -55,7 +55,7 @@ -- 4 for safe decoding as base32hex encodings are optionally padded. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32With` -- and pass in a custom decode function.@@ -74,7 +74,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32 :: Text -> Either Text Text-decodeBase32 = fmap T.decodeLatin1 . B32H.decodeBase32 . T.encodeUtf8+decodeBase32 = fmap T.decodeUtf8 . B32H.decodeBase32 . T.encodeUtf8 {-# INLINE decodeBase32 #-} -- | Attempt to decode a 'ByteString' value as Base32hex, converting from@@ -120,7 +120,7 @@ -- | Decode an unpadded Base32hex encoded 'Text' value. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32WUnpaddedWith` -- and pass in a custom decode function.@@ -136,7 +136,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32Unpadded :: Text -> Either Text Text-decodeBase32Unpadded = fmap T.decodeLatin1+decodeBase32Unpadded = fmap T.decodeUtf8 . B32H.decodeBase32Unpadded . T.encodeUtf8 {-# INLINE decodeBase32Unpadded #-}@@ -170,7 +170,7 @@ -- | Decode an padded Base32hex encoded 'Text' value -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32PaddedWith` -- and pass in a custom decode function.@@ -186,7 +186,7 @@ -- Left "Base32-encoded bytestring requires padding" -- decodeBase32Padded :: Text -> Either Text Text-decodeBase32Padded = fmap T.decodeLatin1+decodeBase32Padded = fmap T.decodeUtf8 . B32H.decodeBase32Padded . T.encodeUtf8 {-# INLINE decodeBase32Padded #-}
src/Data/Text/Lazy/Encoding/Base32.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Safe #-} -- | -- Module : Data.Text.Lazy.Encoding.Base32--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -58,7 +58,7 @@ -- 4 for safe decoding as base32 encodings are optionally padded. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'TL.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'TL.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32With` -- and pass in a custom decode function.@@ -77,7 +77,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32 :: TL.Text -> Either T.Text TL.Text-decodeBase32 = fmap TL.decodeLatin1 . BL32.decodeBase32 . TL.encodeUtf8+decodeBase32 = fmap TL.decodeUtf8 . BL32.decodeBase32 . TL.encodeUtf8 {-# INLINE decodeBase32 #-} -- | Attempt to decode a lazy 'ByteString' value as Base32, converting from@@ -122,7 +122,7 @@ -- | Decode an unpadded Base32 encoded 'TL.Text' value. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'TL.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'TL.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32WUnpaddedWith` -- and pass in a custom decode function.@@ -138,7 +138,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32Unpadded :: TL.Text -> Either T.Text TL.Text-decodeBase32Unpadded = fmap TL.decodeLatin1+decodeBase32Unpadded = fmap TL.decodeUtf8 . BL32.decodeBase32Unpadded . TL.encodeUtf8 {-# INLINE decodeBase32Unpadded #-}@@ -170,7 +170,7 @@ -- | Decode an padded Base32 encoded 'TL.Text' value -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'TL.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'TL.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32PaddedWith` -- and pass in a custom decode function.@@ -186,7 +186,7 @@ -- Left "Base32-encoded bytestring requires padding" -- decodeBase32Padded :: TL.Text -> Either T.Text TL.Text-decodeBase32Padded = fmap TL.decodeLatin1+decodeBase32Padded = fmap TL.decodeUtf8 . BL32.decodeBase32Padded . TL.encodeUtf8 {-# INLINE decodeBase32Padded #-}@@ -230,7 +230,7 @@ -- -- "<<?>>" -- -- -- decodeBase32Lenient :: TL.Text -> TL.Text--- decodeBase32Lenient = TL.decodeLatin1+-- decodeBase32Lenient = TL.decodeUtf8 -- . BL32.decodeBase32Lenient -- . TL.encodeUtf8 -- {-# INLINE decodeBase32Lenient #-}
src/Data/Text/Lazy/Encoding/Base32/Hex.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Safe #-} -- | -- Module : Data.Text.Lazy.Encoding.Base32.Hex--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -58,7 +58,7 @@ -- 4 for safe decoding as base32hex encodings are optionally padded. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'TL.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'TL.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32With` -- and pass in a custom decode function.@@ -77,7 +77,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32 :: TL.Text -> Either T.Text TL.Text-decodeBase32 = fmap TL.decodeLatin1 . BL32H.decodeBase32 . TL.encodeUtf8+decodeBase32 = fmap TL.decodeUtf8 . BL32H.decodeBase32 . TL.encodeUtf8 {-# INLINE decodeBase32 #-} -- | Attempt to decode a lazy 'ByteString' value as Base32hex, converting from@@ -122,7 +122,7 @@ -- | Decode an unpadded Base32hex encoded 'TL.Text' value. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'TL.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'TL.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32WUnpaddedWith` -- and pass in a custom decode function.@@ -138,7 +138,7 @@ -- Left "Base32-encoded bytestring has invalid padding" -- decodeBase32Unpadded :: TL.Text -> Either T.Text TL.Text-decodeBase32Unpadded = fmap TL.decodeLatin1+decodeBase32Unpadded = fmap TL.decodeUtf8 . BL32H.decodeBase32Unpadded . TL.encodeUtf8 {-# INLINE decodeBase32Unpadded #-}@@ -170,7 +170,7 @@ -- | Decode an padded Base32hex encoded 'TL.Text' value -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'TL.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'TL.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32PaddedWith` -- and pass in a custom decode function.@@ -186,7 +186,7 @@ -- Left "Base32-encoded bytestring requires padding" -- decodeBase32Padded :: TL.Text -> Either T.Text TL.Text-decodeBase32Padded = fmap TL.decodeLatin1+decodeBase32Padded = fmap TL.decodeUtf8 . BL32H.decodeBase32Padded . TL.encodeUtf8 {-# INLINE decodeBase32Padded #-}@@ -230,7 +230,7 @@ -- -- "<<?>>" -- -- -- decodeBase32Lenient :: TL.Text -> TL.Text--- decodeBase32Lenient = TL.decodeLatin1+-- decodeBase32Lenient = TL.decodeUtf8 -- . BL32H.decodeBase32Lenient -- . TL.encodeUtf8 -- {-# INLINE decodeBase32Lenient #-}
src/Data/Text/Short/Encoding/Base32.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.Text.Short.Encoding.Base32--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -61,7 +61,7 @@ -- 4 for safe decoding as base32 encodings are optionally padded. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'Data.Text.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'Data.Text.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32With` -- and pass in a custom decode function.@@ -127,7 +127,7 @@ -- | Decode an unpadded Base32 encoded 'ShortText' value. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32UnpaddedWith` -- and pass in a custom decode function.@@ -173,7 +173,7 @@ -- | Decode an padded Base32 encoded 'ShortText' value -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'T.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'T.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32PaddedWith` -- and pass in a custom decode function.
src/Data/Text/Short/Encoding/Base32/Hex.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE Trustworthy #-} -- | -- Module : Data.Text.Short.Encoding.Base32.Hex--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -61,7 +61,7 @@ -- 4 for safe decoding as base32hex encodings are optionally padded. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'Data.Text.Encoding.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'Data.Text.Encoding.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32With` -- and pass in a custom decode function.@@ -127,7 +127,7 @@ -- | Decode an unpadded Base32hex encoded 'ShortText' value. -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'Data.Text.Encoding.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'Data.Text.Encoding.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32UnpaddedWith` -- and pass in a custom decode function.@@ -173,7 +173,7 @@ -- | Decode an padded Base32hex encoded 'ShortText' value -- -- /Note:/ This function makes sure that decoding is total by deferring to--- 'Data.Text.Encoding.decodeLatin1'. This will always round trip for any valid Base32-encoded+-- 'Data.Text.Encoding.decodeUtf8'. This will always round trip for any valid Base32-encoded -- text value, but it may not round trip for bad inputs. The onus is on the -- caller to make sure inputs are valid. If unsure, defer to `decodeBase32PaddedWith` -- and pass in a custom decode function.
test/Internal.hs view
@@ -9,7 +9,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module : Main--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -262,12 +262,12 @@ coarbitrary = coarbitrary . SBS.unpack instance Arbitrary T.Text where- arbitrary = T.pack <$> arbitrary- shrink xs = T.pack <$> shrink (T.unpack xs)+ arbitrary = T.pack . getUnicodeString <$> arbitrary+ shrink xs = T.pack . getUnicodeString <$> shrink (UnicodeString $ T.unpack xs) instance Arbitrary TL.Text where- arbitrary = TL.pack <$> arbitrary- shrink xs = TL.pack <$> shrink (TL.unpack xs)+ arbitrary = TL.pack . getUnicodeString <$> arbitrary+ shrink xs = TL.pack . getUnicodeString <$> shrink (UnicodeString $ TL.unpack xs) instance CoArbitrary T.Text where coarbitrary = coarbitrary . T.unpack
test/Main.hs view
@@ -8,7 +8,7 @@ {-# LANGUAGE RecordWildCards #-} -- | -- Module : Main--- Copyright : (c) 2019-2020 Emily Pillmore+-- Copyright : (c) 2019-2023 Emily Pillmore -- License : BSD-style -- -- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>@@ -170,35 +170,35 @@ prop_padding_invariants :: C a => Harness a -> TestTree prop_padding_invariants Harness{..} = testGroup "prop_padding_invariants" [ testProperty "prop_hex_nopad_roundtrip" $ \(bs :: b) ->- Right (encodeHexNopad bs)- == decodeHexNopad (encodeHexNopad (encodeHexNopad bs))+ Right bs+ == decodeHexNopad (encodeHexNopad bs) , testProperty "prop_hex_pad_roundtrip" $ \(bs :: b) ->- Right (encodeHex bs) == decodeHexPad (encodeHex (encodeHex bs))+ Right bs == decodeHexPad (encodeHex bs) , testProperty "prop_hex_decode_invariant" $ \(bs :: b) ->- ( decodeHexNopad (encodeHexNopad (encodeHex bs))- == decodeHex (encodeHex (encodeHex bs))+ ( decodeHexNopad (encodeHexNopad bs)+ == decodeHex (encodeHex bs) ) ||- ( decodeHexPad (encodeHex (encodeHex bs))- == decodeHex (encodeHex (encodeHex bs))+ ( decodeHexPad (encodeHex bs)+ == decodeHex (encodeHex bs) ) , testProperty "prop_std_decode_invariant" $ \(bs :: b) ->- ( decodeNopad (encodeNopad (encode bs))- == decode (encode (encode bs))+ ( decodeNopad (encodeNopad bs)+ == decode (encode bs) ) ||- ( decodePad (encode (encode bs))- == decode (encode (encode bs))+ ( decodePad (encode bs)+ == decode (encode bs) ) , testProperty "prop_hex_padding_coherence" $ \(bs :: b) ->- Right (encodeHex bs) == decodeHex (encodeHex (encodeHex bs))- && Right (encodeHex bs) == decodeHexPad (encodeHex (encodeHex bs))+ Right bs == decodeHex (encodeHex bs)+ && Right bs == decodeHexPad (encodeHex bs) , testProperty "prop_hex_nopadding_coherence" $ \(bs :: b) ->- Right (encodeHexNopad bs) == decodeHexNopad (encodeHexNopad (encodeHexNopad bs))- && Right (encodeHexNopad bs) == decodeHex (encodeHexNopad (encodeHexNopad bs))+ Right bs == decodeHexNopad (encodeHexNopad bs)+ && Right bs == decodeHex (encodeHexNopad bs) ] -- | just a sanity check against `memory`