Created
June 23, 2016 11:17
-
-
Save anonymous/deaf1dd3ed34e991b3cb18c58c4d8519 to your computer and use it in GitHub Desktop.
the description for this gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val f1: Future[Int] = Future { Thread.sleep(100); 1 } | |
val f2: Future[Int] = Future { Thread.sleep(1000); 2 } | |
val f3: Future[Int] = Future { Thread.sleep(100); 1 } | |
val f4: Future[Int] = Future { Thread.sleep(1000); 2 } | |
import com.thoughtworks.each.Monadic._ | |
import scalaz.std.scalaFuture._ | |
val sum = monadic[Future] { | |
f1.each + f2.each + f3.each + f4.each | |
} | |
sum.onSuccess { case s => println(s"Example 1: $s") } | |
// prints 6 after one second |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment