Leandro Borges Ferreira
10/25/2018, 3:31 AMList<A>
? I know it is impossible in vanilla Kotlin because it doesn't have support Higher Kinded Types. Something like:
public inline fun <F: Iterable, T, R> F<T>.map(transform: (T) -> R): F<R>
Would be impossible. But what about use Arrow and get this:
public inline fun <F: ForIterableK, T, R> Kind<F, T>.mapK(transform: (T) -> R): Kind<F, R>
That would allow set.k.mapK { } to return a SetK, instead of a List
.
Maybe if we have a interface like:
class ForSetK : ForIterableK private constructor() { companion object }
I don't understand how the ForSetK
gets generated, but would it be possible for it to implement Iterable
?