diff --git a/base-encoding.cabal b/base-encoding.cabal index 1b37ea8..b281076 100644 --- a/base-encoding.cabal +++ b/base-encoding.cabal @@ -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 diff --git a/src/Codec/Base16.hs b/src/Codec/Base16.hs index d9a5bb0..21112a0 100644 --- a/src/Codec/Base16.hs +++ b/src/Codec/Base16.hs @@ -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