-
Notifications
You must be signed in to change notification settings - Fork 451
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
Update Either.zipOrAccumulate #2959
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Kover Report
|
a88a9d0
to
1129b23
Compare
1129b23
to
9b3889c
Compare
70e831c
to
0239aaa
Compare
ec4abeb
to
03f2910
Compare
The issue described above has been fixed for this API by a suggestions made by @Zordid. |
0239aaa
to
5ea2cf4
Compare
edb2407
to
9994be8
Compare
i-walker
approved these changes
Mar 7, 2023
Closing this PR since we want to keep the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New Description
Note: Everything mentioned here is open for discussion, so please provide all feedback.
We've introduce earlier
Either.zipOrAccumulate
forcombine + Either
,Either
&EitherNel
. This however doesn't allow intermixing ofEither
&EitherNel
in the same function and thus requires manual lifting in some cases. Defining all different combination would be almost impossible ((9^2)*2 = 162 methods). i.e.Without adding the
162 methods
users need to manually do, although this is the same as before withValidated
.To solve this problem Arrow introduced a DSL
zipOrAccumulate
API that allows binding bothRaise<E>
andRaise<NonEmptyList<E>>
and thus alsoEither<E, ?>
andEitherNel<E, ?>
This serves as a replacement for the accumulate error pattern ofValidated<E, ?>
andValidatedNel<E, ?>
.However this doesn't allow to pass
Either
values, and thus the API forEither
is the same asRaise
with the exception of it getting nesting in the DSL.So this brings the question:
Either.Companion
either { }
toEitherNel()
and work value based? (Note that the current value based implementation could still be derived from the DSL one).Side note: zip deprecation
Arrow is deprecating
Either.zip(fa, fb, f)
in favour ofeither { f(fa.bind(), fb.bind()) }
since it doesn't suffer from the arity-n problem, and offers the exact same behavior. Sinceeither
is nowinline fun
in1.2.0
and thus works with-or-withoutsuspend
it can be used as a drop-in replacement. This has happened so far forEither
,Option
and still needs to happen forIor
,Result
&Nullable
.😅 Unless we're coming back from that (?), the deprecation has not been released yet.Old description
This PR updates
Either.zipOrAccumulate
but sadly since we don't have context receivers yet, and have to emulate throughRaiseAccumulate
it breaks inference /BuilderInference
in a worse way than the PR that started this effort, #2952. This PR the signature with parZipOrAccumulate.We can of-course put off this change, and keep the current signatures until we have context-receivers. The migration path for it is relatively simple, and it will be easily to automate. With
ReplaceWith
(or OpenRewrite).More details below:
If we put
@BuilderInference
on the method, instead of the individual functions we get following error:Some related YouTrack tickets related to the IDEA message:
If we put

@BuilderInference
we get following error for every lambda that tries to bindEitherNel<E>
instead ofEither<E>
and will require to either specify the type arguments in the function, or specify a return type soE
can be inferred from there.The up sight, with context receivers it looks 🔥 😍