Last active
March 21, 2018 15:29
-
-
Save wennergr/9ca09ebfa9ea53705d74294dc9ad6170 to your computer and use it in GitHub Desktop.
Applicative with map2
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[_]] extends Functor[F] { | |
def pure[A](x: A): F[A] | |
def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] | |
def map2[A, B, Z](fa: F[A], fb: F[B])(f: (A, B) => Z): F[Z] = | |
ap(map(fa)(a => (b: B) => f(a,b)))(fb) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment