Created
October 27, 2016 17:59
-
-
Save mmollaverdi/3769611af75f78ae7e8c483a31778533 to your computer and use it in GitHub Desktop.
This file contains 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
trait Applicative[F[_]] { | |
def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] | |
def pure[A](x: A): F[A] | |
def map2[A, B, C](fa: F[A], fb: F[B])(f: (A, B) => C): F[C] = { | |
val fCurried: A => B => C = f.curried | |
val fbc: F[B => C] = ap[A, (B => C)](pure(fCurried))(fa) | |
ap[B, C](fbc)(fb) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment