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

Replace mapN with zip #2315

Merged
merged 21 commits into from Mar 10, 2021
Merged

Replace mapN with zip #2315

merged 21 commits into from Mar 10, 2021

Conversation

nomisRev
Copy link
Member

@nomisRev nomisRev commented Mar 9, 2021

Currently, in Arrow we have mapN from Apply. This PR proposes to replace it in Arrow with zip, which is more in line with the Kotlin Std.

For example the Kotlin Std exposes zip arity 2 for Iterable and instead of duplicating zip with mapN and providing up to arity 10 we can now just extend the Kotlin Std API and expose arity 3-10 for Iterable#zip. Doing so we clearly complement the Kotlin Std instead of proposing alternative APIs.

It also prevents us from having to do 2 deprecation cycles, and will result in a @Deprecated free library @ 0.13.0.

This PR also removes all N based APIs by also replacing parMapN in Arrow Fx Coroutines with parZip.

@nomisRev nomisRev added the 0.12.0 label Mar 9, 2021
@nomisRev nomisRev requested a review from a team March 9, 2021 19:55
@franciscodr
Copy link
Collaborator

Task linked: CU-fb4p28 Replace mapN with zip

i: Either<A, I>,
map: (B, C, D, E, F, G, H, I) -> J
): Either<A, J> =
zip(c, d, e, f, g, h, i, Either.unit, Either.unit) { b, c, d, e, f, g, h, i, _, _ -> map(b, c, d, e, f, g, h, i) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just realized we have Either.unit vs Eval.Unit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either.unit is internal and Eval.Unit is deprecated ;)

Copy link
Member

@raulraja raulraja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nomisRev !

@raulraja raulraja requested a review from a team March 9, 2021 20:00
Comment on lines +257 to +269
* When working with `NonEmptyList` in the `Invalid` side, there is no need to supply `Semigroup` as shown in the example above.
*
* ```kotlin:ank:silent
* import arrow.core.Validated
* import arrow.core.validNel
* import arrow.core.zip
*
* //sampleStart
* val parallelValidate =
* 1.validNel().zip(2.validNel())
* { a, b -> /* combine the result */ }
* //sampleEnd
* ```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@i-walker i-walker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanksk @nomisRev 🙌🏾

@i-walker i-walker merged commit 8a4ea54 into master Mar 10, 2021
@i-walker i-walker deleted the cu-fb4p28-mapn-to-zip branch March 10, 2021 16:06
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.

None yet

4 participants