Here is my code...
val strings: Enumerator[String] = Enumerator("1","2","3","4")
//create am Enumeratee using the map method on Enumeratee
val toInt: Enumeratee[String,Int] = Enumeratee.map[String]{
(s: String) => s.toInt
}
val toSelf: Enumeratee[String,String] = Enumeratee.map[String]{
(s: String) => s
}
List("Mary", "Paul") map (_.toUpperCase) filter (_.length > 5)
val r1 = strings |>> (toSelf &>> (toInt &>> sum))
val r2 = strings |>> toSelf &>> (toInt &>> sum)
val r3 = strings |>> toSelf &>> toInt &>> sum // does not compile
val foo1 = strings &> toInt |>> sum
val foo2 = strings &> (toInt |>> sum) // does not compile
val foo3 = (strings &> toInt) |>> sum
The symbols |>>, &>>. &> are methods. I am confused about the way the compiler is putting parenthesis around them. In the line:
List("Mary", "Paul") map (_.toUpperCase) filter (_.length > 5)
The compiler is inserting the parenthesis like this:
((List("Mary", "Paul") map (_.toUpperCase))) filter (_.length > 5)
In actuality it compiles to:
List("Mary", "Paul").map(((x$3: String) => x$3.toUpperCase()))(List.canBuildFrom[String]).filter(((x$4: String) => x$4.length().>(5)))
In the subsequent example:
strings |>> toSelf &>> (toInt &>> sum)
The compiler is inserting the parenthesis like this:
strings |>> (toSelf &>> (toInt &>> sum))
In actuality it compiles to:
strings.|>> (toSelf.&>> (toInt.&>>(sum)))
Sometimes it seems like the compiler is inserting parenthesis from right to left (second example) and other times it seems the compiler is inserting parenthesis left to right (first example). Sometimes, like in
val r3 = strings |>> toSelf &>> toInt &>> sum
I expect it to insert parenthesis like
val r3 = strings |>> (toSelf &>> (toInt &>> sum))
and instead I get a compiler error.
Can somebody please explain the rules to parenthesis insertion for whitespace delimited methods?