-
Notifications
You must be signed in to change notification settings - Fork 49
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 to cats-effect 3 #500
Conversation
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.
Some notes for reviewers
@@ -11,7 +11,7 @@ lazy val scala3Version = "3.0.0-RC2" | |||
lazy val scala2Versions = Seq(scala212, scala213) | |||
lazy val allScalaVersions = scala2Versions :+ scala3Version | |||
|
|||
skip in publish := true | |||
publish / skip := true |
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.
Deprecated syntax cleanup
@@ -80,18 +80,16 @@ object DatabaseExample { | |||
case (name, id) => Author(id + 1, name) | |||
} | |||
|
|||
def createTransactor[F[_]: Async: ContextShift] = | |||
def createTransactor[F[_]: Async] = |
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.
The typeclass hierarchy is changed quite a bit, in fact it's more or less inverted from CE2: https://typelevel.org/cats-effect/docs/typeclasses
|
||
"We can fetch one user" in { | ||
val io: IO[(Log, User)] = Fetch.runLog[IO](fetchUser(1)) | ||
|
||
val (log, result) = io.unsafeRunSync | ||
val (log, result) = io.unsafeRunSync() |
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.
Fixing deprecated parenthesis auto-application that's dropped in scala3
def parallel[F[_]: Parallel, A](effects: NonEmptyList[F[A]]): F[NonEmptyList[A]] = | ||
effects.parSequence |
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.
The whole method here could probably be deleted; I opted for leaving it in place, but either way would be fine.
Thoughts?
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.
Do you know if parSequence
cancelling all hanging fibers in case of error as well?
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.
Yes, cancellation is part of the contract for parallel IO types. I double checked the code and asked the CE chat to make sure there wasn't some nuanced difference.
I think this code could have been removed in the transition from CE 0.x to 1.x
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.
In that case I'm all up for deleting the method
for { | ||
x <- Fetch.liftIO(IO(3)) | ||
x <- Fetch.liftIO[F, Int](IO(3)) |
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 had some issues with not inferring correctly, since the F
can't be inferred when only appearing in the return
90807a6
to
1c1c075
Compare
@@ -377,7 +376,7 @@ object `package` { | |||
for { | |||
deferred <- Deferred[F, FetchStatus] | |||
request = FetchOne(id, ds.data) | |||
result = deferred.complete _ | |||
result = completeOrFail(deferred) _ |
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.
Deferred#complete
now returns F[Boolean]
instead of failing, so I've restored the "or fail" behavior with a helper
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.
Looks good to me, just added a couple of comments for your consideration :)
def parallel[F[_]: Parallel, A](effects: NonEmptyList[F[A]]): F[NonEmptyList[A]] = | ||
effects.parSequence |
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.
Do you know if parSequence
cancelling all hanging fibers in case of error as well?
This also updates doobie, http4s. The monix example has to be dropped temporarily, since Monix doesn't yet have a CE3-compatible version
By happy accident, today the test was failing due to Github having a brown-out on the deprecated query-param-based auth method. This changes the GithubExample to use an Authorization header instead
CE3 doesn't publish for scala3's RC build, only the release. So this bumps the versions of all crossbuilds to the latest
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.
Looks great @Daenyth , 👍🏻
Either way you wo with the paralell method, feel free to merge from my side.
def parallel[F[_]: Parallel, A](effects: NonEmptyList[F[A]]): F[NonEmptyList[A]] = | ||
effects.parSequence |
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.
In that case I'm all up for deleting the method
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.
LGTM, Thanks @Daenyth !
This also updates doobie, http4s.
The monix example has to be dropped temporarily, since Monix doesn't yet have a
CE3-compatible version
Ref #499