due to the way the type input method works in scala, it cannot determine that it should have a parameter of type last , so it must accept the conservative assumption that it is Nothing .
You can explicitly specify types when calling testFunction :
testFunction[List[Int],Option[Int](last, testValues)
or you can more fully document the relationship between type parameters in a testFunction , which will give additional information about the type:
def testFunction[A, I[_], O[_]](f : I[A] => O[A], inputs : List[I[A]]): List[(I[A], O[A])]
This clearly indicates that I and O are type constructors (kind * → *), now that the input / output types f are more specific, the opponent can correctly conclude that the parameter A for the last function should be Int.
source share