Skip to content

Instantly share code, notes, and snippets.

scala> def apply[A, B](a: A)(f: A => B) = f(a)
apply: [A,B](a: A)(f: (A) => B)B
scala> apply(1)(_ * 2)
res0: Int = 2
scala> def apply[A, B](a: A, f: A => B) = f(a)
apply: [A,B](a: A,f: (A) => B)B
scala> apply(1, _ * 2)
@wrwills
wrwills / OptionGolf.scala
Created October 8, 2010 14:19
applicative_example
import scalaz._
/**
* A simple example of how applicative functors can shorten code
* adapted from chapter 8? of Real World Haskell
*/
object OptionGolf {