Пример использования доброго полиморфизма с AnyKind
Дано
trait Int // proper type
trait List[A] // 1st-order-kinded type constructor
trait Functor[F[_]] // higher-order-kinded type constructor taking type constructor
trait I[H[F[_]]] // higher-order-kinded type constructor taking higher-order type constructor that takes 1st-order type constructor
мы не можем передавать аргумент типа другого типа по сравнению с типом параметра объявленного типа
scala> def f[F[_[_[_]]]] = 42
def f[F[_$1]] => Int
scala> f[I]
val res5: Int = 42
scala> f[Functor]
1 |f[Functor]
| ^
| Type argument Functor does not conform to upper bound [_$1[_$2]] =>> Any
однако мы можем объявить параметр типа полиморфным в своем роде с помощью
scala> def f[A <: AnyKind] = 42
def f[A <: AnyKind] => Int
scala> f[Int]
val res10: Int = 42
scala> f[List]
val res11: Int = 42
scala> f[Functor]
val res12: Int = 42
scala> f[I]
val res13: Int = 42
Каков вариант использования
AnyKind
? Какую практическую задачу это решает?