You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
λ import Data.Text.Encoding
λ import Data.Text.Encoding.Error
λ import Data.ByteString.Lazy (pack)
λ :type pack
pack ∷ [GHC.Word.Word8] → Data.ByteString.Lazy.Internal.ByteString
λ :type streamDecodeUtf8With lenientDecode . pack
<interactive>:1:38: error:
• Couldn't match type ‘Data.ByteString.Lazy.Internal.ByteString’
with ‘bytestring-0.11.4.0:Data.ByteString.Internal.Type.ByteString’
Expected: [GHC.Word.Word8]
→ bytestring-0.11.4.0:Data.ByteString.Internal.Type.ByteString
Actual: [GHC.Word.Word8]
→ Data.ByteString.Lazy.Internal.ByteString
NB: ‘bytestring-0.11.4.0:Data.ByteString.Internal.Type.ByteString’
is defined in ‘Data.ByteString.Internal.Type’
‘Data.ByteString.Lazy.Internal.ByteString’
is defined in ‘Data.ByteString.Lazy.Internal’
• In the second argument of ‘(.)’, namely ‘pack’
In the expression: streamDecodeUtf8With lenientDecode . pack
Decode, in a stream oriented way, a lazy ByteString containing UTF-8 encoded text.
As I understand, my code should work — the pack imported from Data.ByteString.Lazy should compose with streamDecodeUtf8With lenientDecode. It is confusing that we have the same name ByteString for two different things — byte stream and byte array. Maybe I am terribly confused. Please help me understand this situation.
The text was updated successfully, but these errors were encountered:
(bytestring offers type synonyms StrictByteString and LazyByteString, let me use them to reduce confusion)
It's just that documentation for streamDecodeUtf8With is wrong since inception. It takes a StrictByteString indeed. "Stream-oriented" means that you are supposed to pass further StrictByteStrings one by one to Decoding.
See:
This is what the haddock says:
As I understand, my code should work — the
pack
imported fromData.ByteString.Lazy
should compose withstreamDecodeUtf8With lenientDecode
. It is confusing that we have the same nameByteString
for two different things — byte stream and byte array. Maybe I am terribly confused. Please help me understand this situation.The text was updated successfully, but these errors were encountered: