Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Applicative Builder at work
scala> import scalaz._, Scalaz._
import scalaz._
import Scalaz._
scala> import scala.concurrent.Future
import scala.concurrent.Future
scala> import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.ExecutionContext.Implicits.global
scala> (Future(1) |@| Future(2) |@| Future(3)){
| (x,y,z) => x + y + z
| }
res1: scala.concurrent.Future[Int] = scala.concurrent.impl.Promise$DefaultPromise@12f00066
scala> (Future(1) |@| Future(2) ){
| (x,y) => x + y
| }
res2: scala.concurrent.Future[Int] = scala.concurrent.impl.Promise$DefaultPromise@6aea1830
scala> (Future(1) |@| Future("2") ){
| (x,y) => x.toString + y
| }
res3: scala.concurrent.Future[String] = scala.concurrent.impl.Promise$DefaultPromise@7b515368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.