are there some syntactic wins about nested monadic...
# announcements
g
are there some syntactic wins about nested monadic types in kotlin? specifically If I have a
Future<List<A>>
, and I want to map it to a
Future<List<B>>
, is the nicest way to do that:
Copy code
val source: Future<List<Thing>> = //...
source.map { it.map { doTransform(it) } }
or is there something nicer I can do? I suppose I could try to enumerate the entire cartesian product of monadic types, creating custom implementations for each...
Copy code
fun <T, R> Future<List<T>> flatMapList(transform: T -> R) = this.map { it.map { transform(it) } }

//...

source.flatMapList { doTransform(it); }
but enumerating all possible pairs of monads isn't going to be fun.