Created
February 18, 2015 23:10
-
-
Save gszeliga/be710f6bfe9f2d696ef2 to your computer and use it in GitHub Desktop.
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
def applicativeBuilder[E] = new Applicative[({type f[x] = BuildStep[E, x]})#f] { | |
def unit[A](a: A) = Continue(a) | |
override def map2[A, B, C](fa: BuildStep[E, A], fb: BuildStep[E, B])(f: (A, B) => C) = { | |
(fa, fb) match{ | |
case (Continue(a), Continue(b)) => Continue(f(a,b)) | |
case (Failure(e1), Failure(e2)) => Failure(e1) | |
case (f @ Failure(_), _) => f | |
case (_, f @ Failure(_)) => f | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment