-
Notifications
You must be signed in to change notification settings - Fork 449
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
["Request"] more readable alternative to zipOrAccumulate using Kotlin contracts #3066
Comments
If I understand correctly, what you want here is kind of "accumulate as much as possible" scenario. The shape of |
@serras I'm afraid you didn't get the point. The observed behavior of my proposal should be the same as for zipOrAccumulate, just another syntax so to speak. After the ensureAllValid call - as the name suggests - all variables passed as parameters are guaranteed to be Valid. Also, in what sense do you mean independent? |
As |
@Zordid bindAll is slightly different. All Iterable's elements would have to be of type A which is a heavy restriction. Also, destructuring implies redeclaring all variables which often times (at least for me) results in duplicate names (one for the original and one for the validated). Thus, I view my proposal as much more convenient. |
We've managed to create a DSL in this style in #3436 |
I'm closing this since #3436 is now merged. Don't hesitate to reopen if you think we can improve even more. |
What version are you currently using? V1.2
What would you like to see?
I want to have a more readable alternative to zipOrAccumulate, when doing error accumulation.
Motivation:
Currently, zipOrAccumulate works by taking in a number of lambdas whose return values are zipped using another trailing lambda (happy path).
Arrow Docs
zipOrAccumulate's flaws are:
Furthermore this aligns well with current Either DSL (e.g. ensure).
Suggestion:
Use Kotlin contracts to declare a certain variables as valid if they are otherwise accumulate and combine their errors.
Concrete solution's implementation:
This of course would need to be repetitively scaled to a certain number of arguments. The example given consider just two arguments.
Current Limitations:
The text was updated successfully, but these errors were encountered: