Skip to content

The haddock for the function streamDecodeUtf8With says that it takes a byte stream, but in truth it takes a byte array! #542

@kindaro

Description

@kindaro

See:

λ 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

This is what the haddock says:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions