Accepted answer

In scala 2.11 Either is not a Monad. Combinators like flatMap and map are missing from it. Instead, you call .right or .left to get a RightProjection or LeftProjection which does have the combinators. You need to project your Either as right. The code below will return Right(6).

  for {
    x <- Right(1).right
    y <- Right(2).right
    z <- Right(3).right
  } yield x + y + z

Related Query