If I\'m using the F# interpreter, I can define a simple function like this:
> // Function to check if x is an integer multiple of y
> let multipleOf x y =
Yuck! This is one of those occasions where the solution to a question occurs to you just as you're about to submit the question to StackOverflow. Hopefully someone will find it useful if I answer it here myself.
It turns out that Scala will play ball on providing type information for functions as long as you tell it to evaluate the function as a partially evaluated function! In other words, the following does the trick:
scala> multipleOf _
res0: (Int, Int) => Boolean = <function2>
In other words, the REPL gives you information about the type of a function only if you reevaluate the function as a partially evaluated version of itself. This seems significantly less than optimal. ;-)
Perhaps somebody can mention in the comments why it's sane for Scala to approach things this way?
scala> val f = (i: Int, j: Int) => i % j == 0
f: (Int, Int) => Boolean = <function2>
scala> f
res2: (Int, Int) => Boolean = <function2>
scala> def multipleOf(x: Int, y: Int) = x % y == 0
multipleOf: (x: Int, y: Int)Boolean
scala> :type multipleOf(_, _)
(Int, Int) => Boolean