Ammonite-REPL shows higher order function type incorrectly
When a function is declared as follows:
val x: (Int => Option[Int]) => Int = f => f(1).getOrElse(0)
Scala 2.13 console shows an output like the following:
val x: (Int => Option[Int]) => Int = $Lambda$6697/671611988@29952ec6
which shows the correct type of the higher order function x (taking a function parameter of type Int => Option[Int] and returning value of type Int).
When the same is declared in Ammonite REPL, we get following output:
x: Int => Option[Int] => Int = ammonite.$sess.cmd6$$$Lambda$29046/578749177@5567c767
which is missing parenthesis and looks like a curried function that takes an Int and then Option[Int] and return Int. It should've looked like:
x: (Int => Option[Int]) => Int = ammonite.$sess.cmd6$$$Lambda$29046/578749177@5567c767
I followed the code and found that pprint dependency is actually the culprit here. The implicit instance of TPrint for type (Int => Option[Int]) => Int is rendering incorrectly:
println(implicitly[pprint.TPrint[(Int => Option[Int]) => Int]].render)
Gives:
Int => Option[Int] => Int
We can close this here and discuss it at https://github.com/lihaoyi/PPrint/issues/44.
Maybe we can keep this open until https://github.com/lihaoyi/PPrint/issues/44 is resolved, because it directly affects experience with Ammonite-REPL as well and also we'd need to upgrade to fixed pprint version in here, too, which can be done in scope of this issue.
Pull request for resolution available: https://github.com/lihaoyi/PPrint/pull/45