IO
and Cats Effect in general
val longProcess = (IO.sleep(5.seconds) *> IO(println("Ping!"))).foreverM val srv: Resource[IO, ServerBinding[IO]] = for { _ <- longProcess.background server <- server.run } yield server val application = srv.use(binding => IO(println("Bound to " + binding)) *> IO.never)
What's server.run ?
@WickedUk_gitlab where's that example from? looks like http4s.
do you mean what is the type of server.run
? or what are the execution semantics when it happens "after" the background
?
background
, but you're using background
as the non-essential thing when looking from "the outside", which is about starting some server) and not confuse people with the details (server.run
isn't defined in the snippet).