<**> and lift2 #41
-
Hey, how would one use val intMul = (x: Int) => (y: Int) => x * y
val mulParser = intParser1 <**> (intParser2.map(intMul) </> identity[Int]) Is there a better way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yeah, val intMul = (y: Int) => (x: Int) => x * y So that the arguments are reversed, that way it correctly models what you had with the |
Beta Was this translation helpful? Give feedback.
Yeah,
val mulParser = intParser1 <**> intParser2.map(intMul)
will do the trick, but you probably want to define:So that the arguments are reversed, that way it correctly models what you had with the
lift2
: obviously, for an associative operation like*
it doesn't actually matter.