79587238

Date: 2025-04-22 18:46:46
Score: 2
Natty:
Report link

Thanks to @LuisMiguelMejíaSuárez response solution was found. I created but not run IO. Working code sample below:

def task: IO[Int] = {
  println("task 1")
  IO.pure(1)
}

def task2(i: Int): IO[Int] = {
  println(s"task 2: $i")
  IO.pure(i + 1)
}

def task3(i: Int): IO[Int] = {
  println(s"task 3: $i")
  IO.pure(i + 1)
}

def execute: Unit = {

  val mainIO = for {
    task1 <- task
    task2 <- task2(task1)
    _ <- task3(task2)
  } yield ()

  mainIO.handleError(ex => logger.error(ex.getMessage))
    .unsafeRunSync()
}
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @LuisMiguelMejíaSuárez
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Alexander Chernetcov