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

Create a migration guide #1048

Closed
djspiewak opened this issue Aug 7, 2020 · 8 comments · Fixed by #1687
Closed

Create a migration guide #1048

djspiewak opened this issue Aug 7, 2020 · 8 comments · Fixed by #1687
Milestone

Comments

@djspiewak
Copy link
Member

We need to document all the changes we've made in operational terms, so that people know what new type class to use, what functions moved around, what semantics are new can old (especially this!), etc etc. Basically everything you need to know to upgrade to 3.0.

@Daenyth
Copy link
Contributor

Daenyth commented Oct 8, 2020

Collecting some notes as I go:

unsafeToFuture()

import cats.effect.implicits._

def beforeF[F[_]: Effect, A](fa: F[A]): Future[A] = fa.ioIO.unsafeToFuture()
// Note: Using a `Dispatcher` resource is cheap - don't worry about it
def preferredAfterF[F[_]: Async, A](fa: F[A]): F[Future[A]] = Dispatcher[F].use(_.unsafeToFuture(fa))

// Note: It's not certain whether dispatcher passed implicitly will be the canonical style, or whether it will be explicit argument instead
def ifNeededAfterF[F[_], A](fa: F[A])(implicit D: Dispatcher[F]): Future[A] = d.unsafeToFuture(fa)


def beforeIO[A](ioa: IO[A]): Future[A] = ioa.unsafeToFuture()
def afterIO[A](ioa: IO[A]): IO[Future[A]] = Dispatcher[IO].use(_.unsafeToFuture(ioa))
def ifNeededAfterIO(ioa: IO[A])(implicit D: Dispatcher[IO]): Future[A] = D.unsafeToFuture(ioa)

unsafeRunSync()

import cats.effect.implicits._

def beforeF[F[_]: Effect, A](fa: F[A]): A = fa.ioIO.unsafeRunSync()
// Avoid this pattern; instead wrap both the `unsafeRunSync` call *and* the thing that needs it, so that it can be contained within the scope of a `Dispatcher[F].use(...)` block.
def ifNeededAfter[F[_], A)(fa: F[A])(implicit D: Dispatcher[F]): A = D.unsafeRunSync(fa)

def beforeIO[A](ioa: IO[A]): A = ioa.unsafeRunSync()
def afterIO[A](ioa: IO[A]): A = ioa.unsafeRunSync()

Async.fromFuture

def futureApi(): Future[Int]
def before[F[_]: Async: ContextShift]: F[Int] = Async.fromFuture(Sync[F].delay(futureApi()))
def after[F[_]: Async]: F[Int] = Async[F].fromFuture(Sync[F].delay(futureApi()))

Async.async

def intCallback(cb: Either[Throwable, Int] => Unit): Unit

def before[F[_]: Async]: F[Int] = F.async[Int](cb => intCallback(cb))

// Note: 'async_', not 'async' - the 'async_' version preserves the old signature
def after[F[_]: Async]: F[Int] = F.async_[Int](cb => intCallback(cb))

TestContext

// before; libraryDependencies on cats-effect-laws
import cats.effect.laws.util.TestContext

// after; libraryDependencies on cats-effect-testkit
import cats.effect.testkit.TestContext

@kubukoz
Copy link
Member

kubukoz commented Oct 19, 2020

just some ideas for now, I can expand them later. There's plenty left in the readme too:

ContextShift -> Async
Timer -> Temporal
Effect -> Dispatcher (UnsafeRun is gone)
Blocker -> Sync.blocking
Concurrent -> possibly Async or Sync, or even Spawn depending on usage
Bracket -> MonadCancel
shift -> cede (or nothing)
ExitCase -> Outcome/ExitCase
uncancelable -> uncancelable+poll
creating Ref/Deferred -> Ref.Make/Deferred.make
Throwable type aliases / E-parameterized typeclasses
getting a compute EC - Async

@bplommer
Copy link
Contributor

Semaphore#withPermit(...) -> Semaphore#permit.use(_ => ...)

@kubukoz
Copy link
Member

kubukoz commented Oct 20, 2020

@bplommer hopefully that'll be made less cumbersome with #1338

@kubukoz
Copy link
Member

kubukoz commented Nov 28, 2020

If nobody beats me to it, I'll take this one of these days and make something structured.

Note to self: start with the new artifacts.

@djspiewak djspiewak removed the CE3 label Feb 6, 2021
@djspiewak djspiewak added this to the 3.0.0 milestone Feb 7, 2021
@kubukoz
Copy link
Member

kubukoz commented Feb 7, 2021

I have... a branch! And a heading!

image

@djspiewak
Copy link
Member Author

The heading and first sentence are always the hardest part

@kubukoz
Copy link
Member

kubukoz commented Feb 15, 2021

Progress so far: #1687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants