Skip to content

Instantly share code, notes, and snippets.

@globulon
Created February 23, 2012 11:57
Show Gist options
  • Select an option

  • Save globulon/1892539 to your computer and use it in GitHub Desktop.

Select an option

Save globulon/1892539 to your computer and use it in GitHub Desktop.
Function Applicative Functor
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