Higher-kinded types could be cool to have. To be h...
# language-evolution
y
Higher-kinded types could be cool to have. To be honest, I haven't felt a need for them that often, but it feels like a simple enough feature to add. Ideally, it should play well with typealiases too, so we don't have to do the gymnastics that Haskell does. A simple use-case is a Functor type-class (to be used with context params):
Copy code
interface Functor<F<_>> { // Imaginary syntax, based on Scala's F[_]
  fun <A, B> F<A>.map(f: (A) -> B): F<B>
}

object ListFunctor: Functor<List> {
  override fun <A, B> List<A>.map(f: (A) -> B): List<B> = ...
}
It's good to note that Kotlin doesn't have raw types, unlike Java, and so seeing just
List
means the type constructor
List
, and not a raw type equivalent to
List<*>
5