I am little confused about |@| magic in scalaz. Here is my code:
def isThree(x: Int): Validation[NonEmptyList[String], Int] = if (x!= 3){("failed: %d" format x).wrapNel.failure} else {x.success}
println((isThree(6) |@| isThree(7) |@| isThree(13) ) {_ + _ + _})
output: Failure(NonEmptyList(failed: 6, failed: 7, failed: 13)) This is output is what I want.
Here is my questions:
assume I have sequence of Validation, I want to use applicative builder to chain them together.
Seq(isThree(13), isThree(15)).reduceLeft(_ |@| _) why compilation failed due to type not matching ?
It is similar to first question, if I use bracket :
println((isThree(6) |@| (sThree(7) |@| isThree(13)) ) {_ + _ + _})
, it still has compilation errors.
Also, I know I can fix the first one by using <* instead of |@|, but I am still confused why is that, it looks not convenient to use.
Many thanks in advance.