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

Add Fold1 pattern synonym & utilities #212

Merged
merged 6 commits into from
Aug 29, 2024

Conversation

Topsii
Copy link
Contributor

@Topsii Topsii commented Aug 25, 2024

This change extends the API of Control.Foldl.NonEmpty by some of the exports suggested in #209:

  • Fold1_ pattern synonym
  • purely
  • purely_
  • premap
  • handles
  • foldOver
  • folded1

I created a naive benchmark that compares the execution time of

image
Note that the y-axis uses a logarithmic scale.

In this benchmark the current definition of the Fold1 data type clearly performs worse than the alternative definition of Fold1.
The alternative definition of Fold1 performs similar to the Fold(M) variants.
Finally, the Fold* variants all perform worse than NonEmpty.map succ.

Personally, I favor changing the definition of the Fold1 data type and turning the current definition into a pattern synonym. However, in #209 you mentioned you believe

that for most functions the existing definition promotes the greatest code reuse.

Thus, I left the current definition unchanged and added the alternative definition as a pattern synonym.

@Gabriella439 Gabriella439 merged commit 34080ff into Gabriella439:main Aug 29, 2024
4 checks passed
@Gabriella439
Copy link
Owner

Thank you for doing this!

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.

2 participants