Skip to content

Instantly share code, notes, and snippets.

@maowug
Last active December 18, 2015 04:18
Show Gist options
  • Save maowug/88124aeed2eb66af48d4 to your computer and use it in GitHub Desktop.
Save maowug/88124aeed2eb66af48d4 to your computer and use it in GitHub Desktop.
fseq doesnt wrap it
Future.sequence(
Option.empty[Seq[Int]].getOrElse(throw new RuntimeException("mA")).map(Future.apply(_))
) recover {
case e: Throwable => throw new RuntimeException("mB")
}
// // Exiting paste mode, now interpreting.
// java.lang.RuntimeException: mA
// at $anonfun$2.apply(<console>:14)
// at $anonfun$2.apply(<console>:14)
// at scala.Option.getOrElse(Option.scala:121)
// ... 37 elided
// def sequence[A, M[X] <: TraversableOnce[X]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] = {
// in.foldLeft(successful(cbf(in))) {
// (fr, fa) => for (r <- fr; a <- fa) yield (r += a)
// } map (_.result())
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment