--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
Hi Vlad, thanks for your reply!In a previous answer of mine in this thread I tried to clarify my motivation:>Basically, I am concerned about each *explicit* function call, i.e., I am always asking myself if this one is really needed or can I do better by utilizing more adequate combinators, for example.So, as to your post, this would mean: do I really have to explicitly call `flatten` or use adequate library combinators instead. My question was not about how to flatten such a type or why can I do that, but rather if there isn't a more elegant way to do it.First I ended up with what exactly you proposed: "[...] convert Future[List[Future[X]]] into Future[Future[List[X]]], [...] flatten Future[Future[...]] into Future[...]] [...]"val responsesF: Future[List[Future[JValue]]] = ...
val tmp: Future[List[JValue]] = (responesF map (Future.sequence(_))).flatten
But finally:val responseF: Future[List[JValue]] = requestsF flatMap { requests =>Future.sequence(requests map ( req => http(req OK as.json4s.Json) ))}I know there is a `flatten` behind the scenes but it can be easier read, say, is more straightforward and with respect to performance, I guess, standard library combinators are (almost) always better.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.