Appendix C. Higher-kinded types

Higher-kinded types are an advanced language feature that languages like Kotlin and Java do not support. Although this might change in the future, the Arrow team has provided an interim workaround. This solution might not be as intuitive as those found in other languages, but it is still workable. That said, the Arrow team has gone to great lengths to make this feature as easy to use as possible.

C.1 A compiler workaround

Let’s look at the Foldable interface as an example of a higher-kinded type. We declare a new instance of this interface that is a ListFoldable, a Foldable of the List type. Let’s express this exact situation with a snippet of pseudocode:

interface Foldable<F<A>> {
    //some abstract methods

Get Functional Programming in Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.