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

Utf8 text from Chunks #20

Open
Boarders opened this issue Apr 9, 2022 · 2 comments
Open

Utf8 text from Chunks #20

Boarders opened this issue Apr 9, 2022 · 2 comments

Comments

@Boarders
Copy link

Boarders commented Apr 9, 2022

It would be nice to have a function to convert from Chunks to utf8-text in the form of either new text or ShortText as otherwise one has to pass through bytestring.

@andrewthad
Copy link
Member

Chunks are not generally byte sequences of utf-8-encoded text, but in many cases, it's easy for the user to enforce this invariant. I'd take a PR adding a Data.Bytes.Chunks.Unsafe module with a toShortText function and the precondition documented. A similar toText function would be fine, but I cannot require text-2.x as a dependency yet since most of my own projects cannot use text-2.x yet. If you add text >= 1.2 and make the existence of toText conditional on the version of text (omitting it when text < 2.0), that would be fine.

@Boarders
Copy link
Author

Perfect, I am in favour of encouraging ShortText anyway as sliced text rarely seems to be preferable to me. I'll add a PR in the coming week.

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

No branches or pull requests

2 participants