Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Created July 4, 2018 21:14
Scala Cats Monads
object MonadsMain extends App {
import cats.syntax.either._ // for asRight
val a = 3.asRight[String]
val b = 4.asRight[String]
val result = for {
x <- a
y <- b
} yield x * x + y * y
println(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment