Skip to content

Upgrades to Arrow 2.x #83

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

Merged
merged 17 commits into from
Mar 27, 2025
Merged

Upgrades to Arrow 2.x #83

merged 17 commits into from
Mar 27, 2025

Conversation

hugomd
Copy link
Member

@hugomd hugomd commented May 21, 2024

To Do

  • Move outcome to a non-continuations package
  • Add deprecation warnings, with migration paths
  • Determine whether OutcomeEffectScope is sufficient in-place of OutcomeEagerEffectScope. I believe this no longer enforces non-suspending functions
  • Changelog
  • Upgrade Arrow in kotest-extensions-arrow to fix conflicts

Notes

Please see arrow-kt/arrow#2778

@CLAassistant
Copy link

CLAassistant commented May 21, 2024

CLA assistant check
All committers have signed the CLA.

@hugomd hugomd marked this pull request as draft May 21, 2024 07:45
@nomisRev
Copy link
Contributor

Awesome seeing this @hugomd 👏 👏

I'm a bit busy during KotlinConf, but during the summer we're going to work hard relaxing 2.0.0 (final). I will regularly check in here how things are going, but if you come across anything weird please let me know, and tag me and I'll be happy to help in whatever way I can ☺️

Comment on lines 16 to 19
// TODO(hugom): move this into an effect package, instead of continuations to align with arrow (?)
@JvmInline
value class OutcomeEagerEffectScope<E>(private val cont: EagerEffectScope<Either<Failure<E>, Absent>>) :
EagerEffectScope<Either<Failure<E>, Absent>> {
value class OutcomeEffectScope<E>(private val cont: Raise<Either<Failure<E>, Absent>>) :
Raise<Either<Failure<E>, Absent>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be removed, I contributed a Raise impl last year in the raise package.

https://github.com/cashapp/quiver/blob/main/lib/src/main/kotlin/app/cash/quiver/raise/OutcomeBuilder.kt

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome! I'll look at migrating some of our existing codebases over to OutcomeRaise and see how it works out before removing 👍🏻

@hugomd
Copy link
Member Author

hugomd commented Dec 15, 2024

kotest-extensions-arrow is being upgraded to Arrow v2 here: kotest/kotest-extensions-arrow#269

@hugomd hugomd mentioned this pull request Feb 26, 2025
hugomd added 10 commits March 26, 2025 13:11
Validated has been deprecated, and is no longer included in Arrow.
This patch backports ValidatedNel as an alias of an underlying type, and
maintains the existing extensions.
Continuations have been deprecated in favour of the Raise DSL.

I have removed OutcomeEagerEffect scope, as the Raise DSL does not
expose an eager implementation to be extend. Instead, the expectation is
that the caller wraps calls in `eagerEffect`. This binds the suspended
function to an eager context.
kotest-extensions-arrow has not yet been upgrade to arrow 2.0.0, so
we're seeing compatibility issues with some of the older
implementations.

In the meantime, we can add our own Arb to make tests pass.
`OutcomeBuilder` should be used instead, with the following notation:
```kt
outcome {
   Present(1).bind()
}
```
@hugomd hugomd force-pushed the hugom-21-05-2024-arrow-2.0-upgrade branch from 01f96d5 to cf89c0d Compare March 26, 2025 12:40
@hugomd hugomd force-pushed the hugom-21-05-2024-arrow-2.0-upgrade branch from cf89c0d to 43d8e47 Compare March 26, 2025 13:15
@hugomd
Copy link
Member Author

hugomd commented Mar 26, 2025

Finally getting around to updating this. If you've got bandwidth, I'd love another review @nomisRev 🙏🏻

@hugomd hugomd marked this pull request as ready for review March 26, 2025 13:39
@hugomd hugomd changed the title WIP: upgrade to arrow 2.0 Upgrades to Arrow 2.x Mar 26, 2025
Copy link
Member Author

@hugomd hugomd Mar 26, 2025

Choose a reason for hiding this comment

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

This has been marked as deprecated for awhile. I haven't found any usages across GitHub, nor is this used in Quiver generally, so I think it's safe to remove.

@@ -46,28 +43,24 @@ inline fun <ERR, A> A.validateEither(predicate: (A) -> Boolean, error: (A) -> ER
* to pair them. takeLeft will return the value of the left side iff both validations
* succeed.
*
* eg.
* eg:
Copy link
Member Author

Choose a reason for hiding this comment

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

Innocuous, but generally aligning with other usages in comments.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I dig it

Comment on lines -369 to -380
"Validated sequence/traverse" {
Present(1.valid()).sequence().shouldBeValid().shouldBePresent().shouldBe(1)
Present(1.valid()).sequence() shouldBe Present(1).traverse { a: Int -> a.valid() }

val bad: Outcome<String, Validated<String, Int>> = "bad".failure()
bad.sequence().shouldBeValid().shouldBeFailure().shouldBe("bad")

val absent: Outcome<String, Validated<String, Int>> = Absent
absent.sequence().shouldBeValid().shouldBeAbsent()

Present("bad".invalid()).sequence().shouldBeInvalid()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Validated is deprecated arrow-kt/arrow#2795

@@ -129,7 +128,7 @@ class MapTest : StringSpec({
}

"traverse Option short-circuits" {
checkAll(Arb.nonEmptyList(Arb.int())) { ints ->
checkAll(Arb.nel(Arb.int())) { ints ->
Copy link
Member Author

Choose a reason for hiding this comment

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

Kotest now exposes Arb.nel

@hugomd hugomd merged commit 6fdc064 into main Mar 27, 2025
3 checks passed
@hugomd hugomd deleted the hugom-21-05-2024-arrow-2.0-upgrade branch March 27, 2025 06:03
@nomisRev
Copy link
Contributor

@hugomd I gave this a review, and everything looks good to me 🙌

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.

4 participants