Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions base-encoding.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ library
ghc-options: -fno-warn-trustworthy-safe

build-depends:
, base >=4.3 && <4.15
, base16-bytestring ^>=0.1.1.6
, base64-bytestring ^>=1.1.0.0
base >=4.3 && <4.15
, base16-bytestring >=0.1.1.6 && <1.1
, base64-bytestring >=1.0.0.1 && <1.3

, bytestring ^>=0.9.1 || ^>= 0.10.0
, text ^>=1.2.3
, bytestring >=0.9.1 && <0.12
, text >=1.2.3 && <1.3

ghc-options: -Wall
8 changes: 8 additions & 0 deletions src/Codec/Base16.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,25 @@ import Internal

decodeBs2Bs :: BS.ByteString -> Either String BS.ByteString
decodeBs2Bs txt
#if MIN_VERSION_base16_bytestring(1,0,0)
= B16.decode txt
#else
| BS.null rest = Right $! b
| otherwise = Left ("invalid base16 encoding near offset " ++ show (2 * BS.length b))
where
(b,rest) = B16.decode txt
#endif

decodeBsL2BsL :: BS.L.ByteString -> Either String BS.L.ByteString
decodeBsL2BsL txt
#if MIN_VERSION_base16_bytestring(1,0,0)
= B16.L.decode txt
#else
| BS.L.null rest = Right $! b
| otherwise = Left ("invalid base16 encoding near offset " ++ show (2 * BS.L.length b))
where
(b,rest) = B16.L.decode txt
#endif

encodeBs2Bs :: BS.ByteString -> BS.ByteString
encodeBs2Bs = B16.encode
Expand Down