Skip to content

Instantly share code, notes, and snippets.

@SAdams601
Last active August 29, 2015 13:56
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 SAdams601/bae16e3d91e995ea0266 to your computer and use it in GitHub Desktop.
Save SAdams601/bae16e3d91e995ea0266 to your computer and use it in GitHub Desktop.
The patterns in eval that need to modify the state
eval :: Expr -> EvalSt Int
eval (Var v) = do
env <- get
return (head [val | (x,val) <- env, x==v])
eval (Assign x e) = do
v <- eval e
env <- get
put $ (x,v):env
return v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment