Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential decoding helpers? #341

Closed
pearcedavis opened this issue May 13, 2021 · 2 comments
Closed

Potential decoding helpers? #341

pearcedavis opened this issue May 13, 2021 · 2 comments

Comments

@pearcedavis
Copy link
Contributor

pearcedavis commented May 13, 2021

Would any of the following definitions be worth adding to Data.Text.Encoding?

decodeUtf8Either :: ByteString -> Either UnicodeException Text
decodeUtf8Either = decodeUtf8'
decodeUtf8Maybe :: ByteString -> Maybe Text
decodeUtf8Maybe = either (const Nothing) Just . decodeUtf8'
decodeUtf8Lenient :: ByteString -> Text
decodeUtf8Lenient = decodeUtf8With lenientDecode

These are simple enough to define ad hoc, but I thought I'd ask anyway, to save myself from having to do so 🙂.

@pearcedavis pearcedavis changed the title Potential decoding helpers Potential decoding helpers? May 13, 2021
@phadej
Copy link
Contributor

phadej commented May 13, 2021

Virtually all my project specific preludes introduce decodeUtf8Lenient, so 👍 from me.

@pearcedavis
Copy link
Contributor Author

Cool, I'll get a pull request together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants