This file contains hidden or 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
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) |
This file contains hidden or 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
import scalaz._ | |
/** | |
* A simple example of how applicative functors can shorten code | |
* adapted from chapter 8? of Real World Haskell | |
*/ | |
object OptionGolf { |
NewerOlder