I want to transform a list of List[Either[String, Int]]
en Either[String, List[Int]]
. For this, I want to use Cats.sequence :
/* for ammonite users
interp.load.ivy("org.typelevel" %% "cats-core" % "1.0.1")
@
*/
import cats.instances.list._
import cats.instances.either._
import cats.syntax.traverse._
val seqCorrect: List[Either[String, Int]] = List(Right(1), Right(2), Right(3))
val result1 = seqCorrect.sequence
But I have the following error :
Cannot prove that Either[String,Int] <:< G[A].
val result1 = seqCorrect.sequence
^
I found the error message very unhelpful. How do I solve this problem?
I think you may not have enabled partial-unification
. The easiest way to do so, is to add the sbt-partial-unification
plugin.
If you're on Scala 2.11.9 or newer, you can also simply add the compiler flag:
scalacOptions += "-Ypartial-unification"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With