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

FixIor deprecation replacement expressions #2976

Merged
merged 17 commits into from
Mar 27, 2023
Merged

Conversation

gutiory
Copy link
Collaborator

@gutiory gutiory commented Mar 13, 2023

This PR fixes some of the deprecation ReplaceWith suggestions for Ior listed in #2964. I'll update the issue table once this is merged.

And for those replacements that are no working, a section will be created in Arrow website, explaining the best way to migrate these methods.

@gutiory gutiory force-pushed the jg-fix-ior-deprecations branch from cf80546 to 5ddd70f Compare March 13, 2023 14:38
@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2023

Kover Report

File Coverage [59.22%]
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Ior.kt 59.22%
Total Project Coverage 44.16%

@gutiory gutiory marked this pull request as draft March 13, 2023 16:05
@arrow-kt arrow-kt deleted a comment from rafaparadela Mar 16, 2023
@gutiory gutiory marked this pull request as ready for review March 20, 2023 11:32
@gutiory gutiory requested review from serras, nomisRev and franciscodr and removed request for serras March 20, 2023 11:34
Copy link
Collaborator

@franciscodr franciscodr left a comment

Choose a reason for hiding this comment

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

Just a couple of questions. Looks good to me

)
public fun <A, B, C> Ior<A, B>.zip(SA: Semigroup<A>, fb: Ior<A, C>): Ior<A, Pair<B, C>> =
ior(SA::combine) { Pair(this@zip.bind(), fb.bind()) }

@Deprecated(
NicheAPI + "Prefer using the inline ior DSL",
ReplaceWith("ior(SA::combine) { map(this@zip.bind(), c.bind()) }", "arrow.core.raise.ior", "arrow.typeclasses.combine")
ReplaceWith("ior({a, b -> a + b}) { map(this.bind(), c.bind()) }", "arrow.core.raise.ior")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think @serras has asked this in another PR, but being A a generic type, this code won't compile unless we run it under the scope of a Semigroup instance, will it?

Additionally, why do you use the SA::combine function in this ReplaceWith expression and use the plus operator in the rest of zip alternatives?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was actually a bug 😅 . Good catch, @franciscodr !. See 133847c (#2976)

NicheAPI + "Prefer when or fold instead",
ReplaceWith(" MN.run { fold({ f(it) },{ g(it) },{ a,b -> f(a).combine(g(b)) })}")
)
@Deprecated(NicheAPI + "Prefer when or fold instead. See the Arrow web migration guide for more info.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have we created a task for adding these changes to the migration guide?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've just created it 😄 . Thanks for the suggestion, @franciscodr!

@gutiory gutiory merged commit c919e0c into main Mar 27, 2023
@gutiory gutiory deleted the jg-fix-ior-deprecations branch March 28, 2023 14:24
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.

3 participants