WTF is HKT
Higher order functions are functions that returns functions, higher order types are types that returns types. In a poor man's term:
java
class List<T> // "HKT"List takes in a type T and returns List<T>. But, we know that poor Java doesn't have HKT:
java
<T> void foo(List<T> xs) {} // Good
<F, T> void bar(F<T> xs) {} // BadF is an HKT and Java does not allow it, we want:
java
<F<?>, T> void bar(F<T> xs) {}This is doable in Scala:
scala
def foo[F[_], A, B](xs: F[A]): F[B] = ???
// so
def map[F[_] <: Seq[?], A, B](xs: F[A], f: A => B): F[B] = ???Notice that in Kotlin, all Iterable map methods must uniformly return a List, breaking the shape.
Scala win, QED.