Skip to content

Instantly share code, notes, and snippets.

@missingfaktor
Created March 16, 2012 10:27
Show Gist options
  • Select an option

  • Save missingfaktor/2049467 to your computer and use it in GitHub Desktop.

Select an option

Save missingfaktor/2049467 to your computer and use it in GitHub Desktop.
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