This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cats.effect._ | |
| val a = IO(...) | |
| // get access to underlying thread-like abstraction, where you can cancel, cancel is however asynchronous! | |
| val aFiber = a.start | |
| val cancel = aFiber.flatMap(_.cancel) | |
| val join = aFiber.flatMap(_.join) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cats.effect._ | |
| import scala.concurrent.duration._ | |
| def addCoffeePowder(pot: Pot): IO[Pot] = ??? | |
| def addWater(pot: Pot): IO[Pot] = ??? | |
| def waitUntilBoil(heatedPot: Pot): StateT[IO, Unit, FiniteDuration] = ??? | |
| def makeCoffee(pot: Pot): IO[Coffee] = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val fileR: Resource[IO, File] = ... | |
| val socketR1: Resource[IO, Socket] = ... | |
| val socketR2: Resource[IO, Socket] = ... | |
| (for { | |
| file <- fileR | |
| sock1 <- socketR1 | |
| sock2 <- socketR2 | |
| } yield (file, sock1, sock2)).use { |
OlderNewer