-
Notifications
You must be signed in to change notification settings - Fork 448
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 forEachAccumulating and refactor mapOrAccumulate #3367
Conversation
Kover Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of this API, especially because then mapOrAccumulate
becomes simply buildList { forEachOrAccumulate { ... } }
. However, I think that the implementation is quite too convoluted compared to the previous one (I've left a suggestion on how to fix it).
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/RaiseAccumulate.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/RaiseAccumulate.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/raise/RaiseAccumulate.kt
Show resolved
Hide resolved
Note that it's important to keep the semantics of |
wrt |
What I meant here was exposing |
Quick note: I've used |
First discussed on Slack.
This seems to be a useful primitive. I don't know whether exposing the
iterator
methods is a good idea or not. One can always useasSequence
, but with extra wrapping.I also added some missing
mapOrAccumulate
overloads that are refactored from other files.