Created
October 29, 2013 20:29
-
-
Save anonymous/7222017 to your computer and use it in GitHub Desktop.
destructive update extension, the horror!
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
evalThen :: Env a -> Lambda a -> (Maybe (Lambda a) -> b) | |
evalThen env (Var a) then = then $ M.lookup a env | |
evalThen env abs@(Abs {}) then = then $ Just abs | |
evalThen env (App fun arg) then = then $ case fun of | |
Abs id body -> evalThen env arg >>= \a -> evalThen (M.insert id a env) body | |
_ -> Nothing | |
evalThen env p@(Prim {}) = then $ Just p | |
eval env term = eval env term id | |
exec env term = eval env term (\x -> case x of | |
(Var a) -> alter (\y -> x) a env | |
_ -> env) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment