Skip to content

Instantly share code, notes, and snippets.

@fiadliel
Last active July 24, 2016 12:35
Show Gist options
  • Save fiadliel/2bdacbf4dea25d9a1fc41cbd4c00430c to your computer and use it in GitHub Desktop.
Save fiadliel/2bdacbf4dea25d9a1fc41cbd4c00430c to your computer and use it in GitHub Desktop.
import doobie.imports._
import doobie.util.compat.cats.monad._ // todo: make this automatic
import cats._, cats.data._, cats.implicits._
import doobie.util.capture.{Capture => DCapture}
import doobie.util.catchable.{Catchable => DCatchable}
object Implicits {
implicit def doobieCatchable[F[_]](implicit F: ApplicativeError[F, Throwable]): DCatchable[F] = new DCatchable[F] {
def attempt[A](ma: F[A]): F[cats.data.Xor[Throwable, A]] = F.attempt(ma)
def fail[A](t: Throwable): F[A] = F.raiseError(t)
}
implicit def doobieCapture[F[_]](implicit F: Applicative[F]): DCapture[F] = new DCapture[F] {
def apply[A](a: => A): F[A] = F.pureEval(Eval.always(a))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment