score:5
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
Source: stackoverflow.com
Related Query
- Right not working with for comprehension Scala
- EitherT in Scala not working with For Comprehension
- AWS Credentials for lambda when working with scala not working
- scala regex replace not working with multiple patterns and for capital newline
- Creating an implicit function that wraps map() in Scala with the right type: Not for the faint at heart
- getStrLn in ZIO working with flatMap but not inside for comprehension
- Scala API with encode special character not working for client
- Scala: Imported scala object with implicits not working for providing Read or Write format (play json)
- Scala plugin and Rational Developer for System z with Java not working
- Working with YAML for Scala
- Scala Future with filter in for comprehension
- java try-with-resource not working with scala
- IntelliJ IDEA Hotkey for comment does not work with Scala
- Regex unapply in for comprehension with if guard not compiling
- Scala for comprehension with future and options
- Scala println not working with App trait
- Debug not working with play framework activator, scala and eclipse
- explanation on scala for comprehension with Option
- Scala IDE not working properly in Eclipse Luna for Java EE
- Scala working with Java libraries not specifying collections' type parameters
- Scala for comprehension with Future, List and Option
- for comprehension with tuple, withFilter is not a member error
- scala macro with a import statement not working
- Why this simple Scala for comprehension does not execute the futures?
- Scala type inference not working with generic case class and lambda
- For comprehension with IO-monad in Scala
- Order By Timestamp is not working for Date time column in Scala Spark
- Scala foldLeft performance 4x worse than for loop when working with floats
- Scala pattern matching with disjunctions not working
- Scala PartialFunction with isDefinedA and apply not working
More Query from same tag
- fs2.Stream hangs on taking twice
- What if there is no match type?
- Add Up Values in a Map with Multiple Lists in Scala
- akka actor generic receive method
- IntelliJ dependency package not found
- Why does this simple quill quote fails to compile?
- trait Enumeratee is invariant in type From when using ADT
- Storing and sharing a cookie for service access in Scala
- Retrieving an ActorSelection from a Trait in akka/scala
- Scala Fold Function Mismatch type
- Scala: Read variables defined in shell script
- Suppress display of a result in scala worksheet
- understanding scala generics from class signature
- Can't fetch plugins from repositories with scala's sbt
- Not able to remove folder name inspite of delting all files inside it in spark
- Scala Eclipse IDE configuration
- how to efficiently build up complex case class in my app flow?
- How can I catch a BlockMissingException when reading files using Spark sc.textFile?
- Remove both duplicates row
- spark UDF don't accept Array
- Pattern for responding with async result
- Scala 3 - Instantiate class from List[String]
- MapReduce implementation in Scala
- Scala Yield generators
- Concurrency, how to create an efficient actor setup?
- Functional combinator for filter then map
- Cross language simple expression language implementation
- Querying on Date in Mongo
- Setting a module project in Scala as an sbt project?
- NoClassDefFoundError while writing to Azure SQL using AD authetication in Dataproc cluster. But Works fine in Local