Hi folks. Wouldn't it be possible for the the SetK...
# arrow
l
Hi folks. Wouldn't it be possible for the the SetK, MapK or any other data structure return itself from a map(), instead of just
List<A>
? I know it is impossible in vanilla Kotlin because it doesn't have support Higher Kinded Types. Something like:
Copy code
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:
Copy code
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:
Copy code
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
?