Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
Created May 6, 2019 17:19
Show Gist options
  • Save kevinmeredith/241173ffdbedf8509942b971516e17dd to your computer and use it in GitHub Desktop.
Save kevinmeredith/241173ffdbedf8509942b971516e17dd to your computer and use it in GitHub Desktop.
@ import $ivy.`org.typelevel::cats-effect:0.10.1`
import $ivy.$
@ import cats.effect.IO, cats.implicits._
import cats.effect.IO, cats.implicits._
@ val foo: IO[Either[String, Int]] = IO(throw new RuntimeException("!"))
foo: IO[Either[String, Int]] = Delay(ammonite.$sess.cmd2$$$Lambda$2001/359985955@1bbfd42f)
@ foo.attempt
res3: IO[Either[Throwable, Either[String, Int]]] = Bind(Delay(ammonite.$sess.cmd2$$$Lambda$2001/359985955@1bbfd42f), <function1>)
@ foo.attempt.unsafeRunSync match {
case Left( rte : RuntimeException ) => true
case _ => false
}
res4: Boolean = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment