What is a higher kind type ?

I am coming from an OOP and learning FP and I have met alot of new concepts and this one of them. So what is a higher kind and how to achieve this with Kotlin ?

Agnishom Chattopadhyay's photo

I do not know Kotlin, so I will code most of my answer in Haskell. However, I took a look at this blog and I am pretty sure that the idea is similar.

So, first off, values live in types. For example, 4 :: Int, meaning that the value 4 is of the type Int. But, what is Int? We answer that question by saying that Int :: *, meaning that Int of the kind * (type).

However, there is more to types than just the base types. For example, [1, 2, 3] :: [] Int, indicating that [1, 2, 3] is a [] (list) of Ints. But then, what exactly is []? The answer to that question is [] :: * -> *, i.e, [] is a type constructor.

So, in summary, such things are what we mean by higher kinded types. They are not types themselves, but functions on the space of types.

If you are interested in a very theoretical answer, checkout System F_omega

Stephen Florentino's photo

Edited--op is asking about Higher-kinded Type (HKT) and not higher order type.

AFAIK there is not any language-level support for HKT in Kotlin. Maybe someday? github.com/Kotlin/KEEP/pull/87

_Original Response: Have a look at en.wikipedia.org/wiki/Higher-order_function. There is a section there for Kotlin._

Muhammad Al-kady's photo

Is higher kind is the same as higher order function ?

Stephen Florentino's photo

Full StackOverflow Developer

No, they are not the same. Edited answer.