-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
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 |
// 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>> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍🏻
|
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() } ```
01f96d5
to
cf89c0d
Compare
cf89c0d
to
43d8e47
Compare
Finally getting around to updating this. If you've got bandwidth, I'd love another review @nomisRev 🙏🏻 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it
"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() | ||
} |
There was a problem hiding this comment.
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 -> |
There was a problem hiding this comment.
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 I gave this a review, and everything looks good to me 🙌 |
To Do
OutcomeEffectScope
is sufficient in-place ofOutcomeEagerEffectScope
. I believe this no longer enforces non-suspending functionsNotes
Please see arrow-kt/arrow#2778