Skip to content

Instantly share code, notes, and snippets.

@debasishg
Created November 18, 2010 13:32
Show Gist options
  • Save debasishg/704973 to your computer and use it in GitHub Desktop.
Save debasishg/704973 to your computer and use it in GitHub Desktop.
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> implicitly[Applicative[Option]]
res0: scalaz.Applicative[Option] = scalaz.Applicative$$anon$1@78b973
scala> val f = ((_: Int) * (_: Int)).curried
f: (Int) => (Int) => Int = <function1>
scala> Some(10) <*> (Some(20) map f)
<console>:19: error: type mismatch;
found : Option[(Int) => Int]
required: Some[(Int) => ?]
Some(10) <*> (Some(20) map f)
^
scala> val o1: Option[Int] = Some(10)
o1: Option[Int] = Some(10)
scala> val o2: Option[Int] = Some(20)
o2: Option[Int] = Some(20)
scala> o1 <*> (o2 map f)
res2: Option[Int] = Some(200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment