Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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