Skip to content

Instantly share code, notes, and snippets.

@tomaszperek
Created October 19, 2015 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaszperek/b5bb02332bf566e0c00b to your computer and use it in GitHub Desktop.
Save tomaszperek/b5bb02332bf566e0c00b to your computer and use it in GitHub Desktop.
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