Doobie book says that it\'s a good practice to return ConnectionIO from your repository layer. It gives an ability to chain calls and perform them in one transaction. Nice
ConnectionIO
in doobie has a cats.effect.Async instance, which, among other things, allows you do turn any cats.effect.IO
into ConnectionIO
by means of liftIO
method:
import doobie.free.connection._
import cats.effect.{IO, Async}
val catsIO: IO[String] = ???
val cio: ConnectionIO[String] = Async[ConnectionIO].liftIO(catsIO)
For monix.eval.Task
, your best bet is using Task#toIO
and performing the same trick, but you'd need a monix Scheduler
in scope.