Skip to content

Instantly share code, notes, and snippets.

@labra
Created August 5, 2016 21:34
Show Gist options
  • Save labra/e939f5aa82860548abbd5b59a37fc13e to your computer and use it in GitHub Desktop.
Save labra/e939f5aa82860548abbd5b59a37fc13e to your computer and use it in GitHub Desktop.
Example using eff-cats with catchWrong
package examples
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
object ExampleCatchWrong {
type E = String
type Comput = Validate[E, ?] |: NoEffect
type Check[A] = Eff[Comput,A]
def runCheck[A](c: Check[A]) = c.runNel.run
val comp1: Check[Int] = for {
_ <- wrong[Comput,E]("1")
_ <- wrong[Comput,E]("2")
} yield 0
val handle: E => Check[Int] = { case e => pure(e.toInt) }
val comp2: Check[Int] = catchWrong(comp1)(handle)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment