It should be as follows:
scala> def fn2(f: Int => Int => Int) = f
fn2: (f: Int => (Int => Int))Int => (Int => Int)
scala> fn2(fn)(1)(2)
res5: Int = 3
(Int)(Int) => Intfalse - should be used instead Int => Int => Int(e.g. in Haskell). In fact, the curried function accepts Intand returns a Int => Intfunction.
PS You can also use fn2(fn _)(1)(2), since the transfer fnin the previous example is just a short form of eta extension, see Differences between using underscores in these scala methods .
source
share