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

Update to cats-effect 3 #500

Merged
merged 4 commits into from
Jun 10, 2021
Merged

Update to cats-effect 3 #500

merged 4 commits into from
Jun 10, 2021

Conversation

Daenyth
Copy link
Contributor

@Daenyth Daenyth commented Jun 9, 2021

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

Copy link
Contributor Author

@Daenyth Daenyth left a 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
Copy link
Contributor Author

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] =
Copy link
Contributor Author

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()
Copy link
Contributor Author

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

Comment on lines +24 to +25
def parallel[F[_]: Parallel, A](effects: NonEmptyList[F[A]]): F[NonEmptyList[A]] =
effects.parSequence
Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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

fetch/src/main/scala/fetch.scala Outdated Show resolved Hide resolved
for {
x <- Fetch.liftIO(IO(3))
x <- Fetch.liftIO[F, Int](IO(3))
Copy link
Contributor Author

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

@Daenyth Daenyth force-pushed the CE3 branch 2 times, most recently from 90807a6 to 1c1c075 Compare June 9, 2021 18:52
@@ -377,7 +376,7 @@ object `package` {
for {
deferred <- Deferred[F, FetchStatus]
request = FetchOne(id, ds.data)
result = deferred.complete _
result = completeOrFail(deferred) _
Copy link
Contributor Author

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

pepegar
pepegar previously approved these changes Jun 10, 2021
Copy link
Contributor

@pepegar pepegar left a 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 :)

Comment on lines +24 to +25
def parallel[F[_]: Parallel, A](effects: NonEmptyList[F[A]]): F[NonEmptyList[A]] =
effects.parSequence
Copy link
Contributor

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?

fetch/src/main/scala/fetch.scala Outdated Show resolved Hide resolved
Daenyth added 2 commits June 10, 2021 09:01
This also updates doobie, http4s.

The monix example has to be dropped temporarily, since Monix doesn't yet have a
CE3-compatible version
Daenyth added 2 commits June 10, 2021 09:31
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
@Daenyth Daenyth marked this pull request as ready for review June 10, 2021 14:04
Copy link
Contributor

@pepegar pepegar left a 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.

Comment on lines +24 to +25
def parallel[F[_]: Parallel, A](effects: NonEmptyList[F[A]]): F[NonEmptyList[A]] =
effects.parSequence
Copy link
Contributor

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

Copy link
Contributor

@juanpedromoreno juanpedromoreno left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks @Daenyth !

@Daenyth Daenyth merged commit 6a99307 into main Jun 10, 2021
@Daenyth Daenyth deleted the CE3 branch June 10, 2021 15: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.

3 participants