Can a function literal use type parameter in Scala?
scala
Solution
The blog post First-class polymorphic function values in shapeless (1 of 3) — Function values in Scala seems to imply that there's no way in "standard" Scala to have polymorphic function values:
We can have first-class monomorphic function values and we can have second-class polymorphic methods, but we can't have first-class polymorphic function values ... at least we can't with the standard Scala definitions.
It looks like we need a library like shapeless.
Problem
Given the following definition of a method `removeAt` that's polymorphic: ``` def removeAt[T](n: Int, ts: Seq[T]): (Seq[T], T) = ??? ``` How can I declare a list of `removeAt`-like functions? Can a function literal use type parameter? How can I make the following compilable and able to contain `removeAt`? ``` List[(Int, Seq[_]) => (Seq[_], _)](removeAt) ``` UPDATE: Why does the following work fine so I can `foreach` over the list and execute the functions? That's exactly what I needed in the first place. ``` val solutions = Seq[(Int, Seq[Any]) => (Seq[Any], Any)]( removeAt ) ```