Created
February 23, 2012 11:57
-
-
Save globulon/1892539 to your computer and use it in GitHub Desktop.
Function Applicative Functor
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
| case class FunctionApplicative[A]() extends Applicative[({type λ[α] = Function[A,α]})#λ]{ | |
| def apply[T](data: T): (A) ⇒ T = ( _ ⇒ data) | |
| def flatten[T](m: (A) ⇒ (A) ⇒ T): (A) ⇒ T = (x: A) ⇒ m(x)(x) | |
| def map[T, P >: T, U](source: (A) ⇒ T)(f: (P) ⇒ U): (A)⇒ U = f.compose(source) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment