Closed
Description
Compiler version
val scala3Version = "3.3.3"
with cats core library
libraryDependencies += "org.typelevel" %% "cats-core" % "2.12.0"
import scala.concurrent.{ Future, ExecutionContext }
import scala.concurrent.ExecutionContext.Implicits.global
import cats.data.EitherT
import cats.syntax.all._
type FuEiErr[T] = Future[Either[Error, T]]
case class Error(msg: String)
def fA(x:Int): FuEiErr[Int] = Future(Right(x))
def fB(x:Int): FuEiErr[Int] = Future(Right(x))
@main def TestEitherT(): Unit =
(for
a <- EitherT(fA(7))
b <- EitherT(fB(42))
yield a+b).value.map {
case Left(err) => println(s"Error: ${err.msg}")
case Right(res) => println(s"Result: ${res}")
}
Output
[error] -- [E172] Type Error: ...src/main/scala/Main.scala:16:11
[error] 16 | yield a+b).value.map {
[error] | ^
[error] |No given instance of type cats.Functor[[X0] =>> scala.concurrent.Future[Either[Error, X0] | X0]] was found for parameter F of method map in class EitherT
Expectation
No compilation error, works in version 2.13