Skip to content

Feature request: Stream decoding with "stop" as the error behavior #498

@chris-martin

Description

@chris-martin

I am considering a situation where I have a ByteString stream that may be UTF-8 up to some unknown point, and I'd like to be able to do a streaming decode of as much Text as possible for as long as the input is valid, and then stop at the first sign of trouble, obtaining both the decoded Text and the non-UTF8 ByteString remainder.

I envision something like this:

streamDecodeUtf8' :: ByteString -> Decoding'

data Decoding' = Some'
    Text -- ^ What was decoded
    ByteString -- ^ Remainder that was not decoded
    (Maybe UnicodeException)
        -- ^ 'Just' an exception if the remainder is non-empty
        -- because it begins with invalid input.
        -- 'Nothing' if the remainder is empty or is non-empty
        -- but could become valid with more input.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions