Closed emilypi closed 2 years ago
For Monoid/Semigroup mappends, the laws are that f (a <> b) = f a <>' f b. However, that law does not hold for Bytestring64:
mappends
f (a <> b) = f a <>' f b
Bytestring64
П> getEncodedByteString64 "foob" <> getEncodedByteString64 "ar" -- encodes "foob" and "ar" "Zm9vYg==YXI=" -- not valid П> getEncodedByteString64 $ "foob" <> "ar" "Zm9vYmFy"
The solution here is you have to trim pads and statefully shift bits to reassemble a new bytestring with new pads. These instances are only valid for bytestrings modulo lenient decoding as is.
For Monoid/Semigroup
mappends
, the laws are thatf (a <> b) = f a <>' f b
. However, that law does not hold forBytestring64
:The solution here is you have to trim pads and statefully shift bits to reassemble a new bytestring with new pads. These instances are only valid for bytestrings modulo lenient decoding as is.