Usage
Just use io-silent
and make sure the last value the codeblock returns is
of type IO[_]
, for example:
```scala mdoc:io-silent
import cats.effect._
import scala.concurrent._
import scala.concurrent.duration._
import cats.syntax.all._
implicit val tm = IO.timer(ExecutionContext.global)
implicit val cs = IO.contextShift(ExecutionContext.global)
def go(i: Int): IO[Unit] = i match {
case 0 => IO.unit
case n => IO.sleep(5.millis) *> IO(println(s"tick $i")) >> go(n - 1)
}
go(10)
```
Which will be executed, the output captured and rendered separately:
import cats.effect._
import scala.concurrent._
import scala.concurrent.duration._
import cats.syntax.all._
implicit val tm = IO.timer(ExecutionContext.global)
implicit val cs = IO.contextShift(ExecutionContext.global)
def printIO(s: Any) = IO(System.out.println(s))
def go(i: Int): IO[Unit] = i match {
case 0 => IO.unit
case n => IO.sleep(5.millis) *> printIO(s"tick $i") >> go(n - 1)
}
go(10)
tick 10
tick 9
tick 8
tick 7
tick 6
tick 5
tick 4
tick 3
tick 2
tick 1