scala-cats

How to sequence Either with Scala cats without a type alias (see Herding cats)

痞子三分冷 提交于 2019-11-29 12:24:20
I was reading Herding Cats The final example on the Traverse page on sequencing List of Either failed for me. in the example they do this:- scala> List(Right(1): Either[String, Int]).sequence res5: Either[String,List[Int]] = Right(List(1)) scala> List(Right(1): Either[String, Int], Left("boom"): Either[String, Int]).sequence res6: Either[String,List[Int]] = Left(boom) But When I try I get the following error:- scala> import cats._, cats.data._, cats.implicits._ scala> val les = List(Right(3):Either[String,Int], Right(2):Either[String,Int]) scala> les.sequence <console>:37: error: Cannot prove

How to sequence Either with Scala cats without a type alias (see Herding cats)

走远了吗. 提交于 2019-11-28 04:59:47
问题 I was reading Herding Cats The final example on the Traverse page on sequencing List of Either failed for me. in the example they do this:- scala> List(Right(1): Either[String, Int]).sequence res5: Either[String,List[Int]] = Right(List(1)) scala> List(Right(1): Either[String, Int], Left("boom"): Either[String, Int]).sequence res6: Either[String,List[Int]] = Left(boom) But When I try I get the following error:- scala> import cats._, cats.data._, cats.implicits._ scala> val les = List(Right(3)