Created
March 17, 2021 02:09
-
-
Save chenharryhua/323bbe143a32794f33828bbafeabb6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.syntax.all._ | |
import cats.data._ | |
import cats._ | |
val f = Validated.invalid[Eval[String], Eval[Int]](Eval.always { println("eval fail"); "oops" }) | |
val s = Validated.valid[Eval[String], Eval[Int]](Eval.always { println("eval succ"); 1 }) | |
val combine: Validated[Eval[String], Eval[Int]] = f *> s | |
val res = combine.bimap(_.value, _.value) match { | |
case Validated.Valid(a) => println(a) | |
case Validated.Invalid(e) => println(e) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
compare to
f and s both evaluated in Validated. only f is evaluated in Either