Skip to content

conversions between NonEmptyArray/NonEmptyString #102

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

Merged
merged 4 commits into from
May 18, 2018

Conversation

matthewleon
Copy link
Contributor

addresses #101

This uses unsafePartial for the sake of efficiency.

@matthewleon
Copy link
Contributor Author

rebased on master

addresses purescript#101

This uses unsafePartial for the sake of efficiency.
@matthewleon
Copy link
Contributor Author

I've added some benchmarks to the branch. For longer strings, I'm getting fromNonEmptyCharArray taking an average of 50.49 μs, and fromFoldable1 taking 69.56 μs: there's definitely a decent improvement there, though nothing order-of-magnitude.

It will be interesting to compare toNonEmptyCharArray to an eventual toUnfoldable1. See purescript/purescript-unfoldable#19

That being said, there is probably something to be said in favor of the API for NonEmptyString mirroring that of plain String. Besides which, this is almost always the conversion you want, anyway: how often will we see people converting between Strings and NonEmptyList Chars, for example?

I think this is worth adopting on those grounds.

@MonoidMusician
Copy link
Contributor

Hey looks neat :) I would like to see CodePoint conversions as well, since they make working with unicode nicer.

@garyb garyb changed the base branch from master to compiler/0.12 May 18, 2018 14:39
@garyb
Copy link
Member

garyb commented May 18, 2018

👍 on codepoints, but we can add that separately as it's non-breaking at least 🙂

@garyb garyb merged commit 0e6048f into purescript:compiler/0.12 May 18, 2018
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

Successfully merging this pull request may close these issues.

4 participants