Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created January 16, 2017 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/a457bec3e99597b946ca04ea61700999 to your computer and use it in GitHub Desktop.
Save deque-blog/a457bec3e99597b946ca04ea61700999 to your computer and use it in GitHub Desktop.
type Env = Map.Map String Int
eval :: Env -> Expr -> Int
eval env (Cst n) = n
eval env (Var v) = env Map.! v
eval env (Op Add xs) = sum $ map (eval env) xs
eval env (Op Mul xs) = product $ map (eval env) xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment