Skip to content

conversions between NonEmptyArray/NonEmptyString#102

Merged
garyb merged 4 commits intopurescript:compiler/0.12from
matthewleon:nonemptyarray
May 18, 2018
Merged

conversions between NonEmptyArray/NonEmptyString#102
garyb merged 4 commits intopurescript:compiler/0.12from
matthewleon:nonemptyarray

Conversation

@matthewleon
Copy link
Copy Markdown
Contributor

addresses #101

This uses unsafePartial for the sake of efficiency.

@matthewleon
Copy link
Copy Markdown
Contributor Author

rebased on master

addresses purescript#101

This uses unsafePartial for the sake of efficiency.
@matthewleon
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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