I am talking about this (and only about parametric polymorphism):
def fun1[T](s: Set[T]): Option[T] = s.headOpton
I have seen in several places when people call this an example of a polymorphic function around Tin raw scala - something like formless Set ~> Option.
But I do not understand why we can call it polymorphic. Despite the fact that we seem to be able to go there as Set[Int]well as Set[String]in fact, fun1[Int]and fun1[String]- two different functions. I think I can argue that since the eta extension fun1is wrong and does not give us what we want:
scala> fun1 _
res0: Set[Nothing] => Option[Nothing] = <function1>
And we should always indicate the type when expanding:
scala> fun1[Int]_
res1: Set[Int] => Option[Int] = <function1>
, scala - , . ?