Created
February 24, 2015 22:14
-
-
Save gszeliga/e54930e6a2013c43a804 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
final class SmartBuilder[A,B](val f: BuildStep[Throwable,A => B]) | |
{ | |
def @> [E <: Throwable](step: BuildStep[E,A])(implicit applicative: Applicative[({type f[x] = BuildStep[Throwable, x]})#f]) = { | |
applicative.apply(f)(step) | |
} | |
} | |
object SmartBuilderOps | |
{ | |
def <<= [A](f: BuildStep[Throwable, A]) = f match { | |
case Continue(v) => v | |
case Failure(e) => e | |
} | |
implicit val applicative = applicativeBuilder[Throwable] | |
implicit def build[A,B](s: BuildStep[Throwable,A => B])=new SmartBuilder(s) | |
implicit def smartify[A,B,C](target: Curryable[A,B,C])(implicit applicative: Applicative[({type f[x] = BuildStep[Throwable, x]})#f]) = build(applicative.unit(target.curried)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment