In the book Functional Programming, Scala provides an example of "Lift" in which a function of type A => B promoted to Option[A] => Option[B] .
Here's how the elevator is implemented:
def lift[A,B](f: A => B):Option[A] => Option[B] = _ map f
I have a couple of confusions about this:
First, what is there? Secondly, when I remove the return type from def, expecting the output type to do its magic, I get the following exception:
scala> def lift[A,B](f: A => B) = _ map f <console>:7: error: missing parameter type for expanded function ((x$1) => x$1.map(f)) def lift[A,B](f: A => B) = _ map f
Can someone explain what is going on here?
thanks
source share