Created
January 20, 2017 20:25
-
-
Save deque-blog/ce001c284883728133cb773be7e643e8 to your computer and use it in GitHub Desktop.
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
eval :: Env -> Expr -> Int | |
eval env = cata algebra where | |
algebra (Cst n) = n | |
algebra (Var x) = env Map.! x | |
algebra (Op Add xs) = sum xs | |
algebra (Op Mul xs) = product xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment