Created
March 16, 2012 10:27
-
-
Save missingfaktor/2049467 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
| implicit object ExprApplicative extends Applicative[Expr] { | |
| def pure[A](a: => A): Expr[A] = Lit(a) | |
| override def fmap[A, B](e: Expr[A], f: A => B): Expr[B] = new Expr[B] { | |
| def eval(st: SymbolTable): B = f apply e.eval(st) | |
| } | |
| override def apply[A, B](f: Expr[A => B], e: Expr[A]): Expr[B] = new Expr[B] { | |
| def eval(st: SymbolTable): B = f.eval(st) apply e.eval(st) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment