groostav
07/21/2016, 12:12 AMFuture<List<A>>
, and I want to map it to a Future<List<B>>
, is the nicest way to do that:
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...
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.