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()
}