Skip to content

Instantly share code, notes, and snippets.

@fiadliel
Created July 24, 2016 11:33
Show Gist options
  • Save fiadliel/3766298682aaf424f4df71b0c9bc6048 to your computer and use it in GitHub Desktop.
Save fiadliel/3766298682aaf424f4df71b0c9bc6048 to your computer and use it in GitHub Desktop.
import doobie.util.catchable.{Catchable => DCatchable}
import doobie.util.capture.{Capture => DCapture}
import fs2.Task
import fs2.util.Effect
object Implicits {
implicit def doobieCatchable[F[_]](implicit F: Effect[F]): DCatchable[F] = new DCatchable[F] {
def attempt[A](ma: F[A]): F[cats.data.Xor[Throwable, A]] =
F.attempt(ma).map(_.fold(Xor.left, Xor.right))
def fail[A](t: Throwable): F[A] = F.fail(t)
}
implicit def doobieCapture[F[_]](implicit F: Effect[F]): DCapture[F] = new DCapture[F] {
def apply[A](a: => A): F[A] = F.delay(a)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment