on master help sign in
Look in the environment before the definitions in executor
0029900David Christiansen
src/Core/Execute.hs+2
@@ -167,6 +167,7 @@ ioUnit = ioWrap (EP Ref unitCon EErased)
167type ExecEnv = [(Name, ExecVal)]
167type ExecEnv = [(Name, ExecVal)]
168
168
169doExec :: ExecEnv -> Context -> Term -> Exec ExecVal
169doExec :: ExecEnv -> Context -> Term -> Exec ExecVal
170+doExec env ctxt p@(P Ref n ty) | Just v <- lookup n env = return v
170doExec env ctxt p@(P Ref n ty) =
171doExec env ctxt p@(P Ref n ty) =
171 do let val = lookupDef n ctxt
172 do let val = lookupDef n ctxt
172 case val of
173 case val of
@@ -392,6 +393,7 @@ execCase env ctxt ns sc args =
392 let arity = length ns in
393 let arity = length ns in
393 if arity <= length args
394 if arity <= length args
394 then do let amap = zip ns args
395 then do let amap = zip ns args
396+-- trace ("Case " ++ show sc ++ "\n in " ++ show amap ++"\n in env " ++ show env ++ "\n\n" ) $ return ()
395 caseRes <- execCase' env ctxt amap sc
397 caseRes <- execCase' env ctxt amap sc
396 case caseRes of
398 case caseRes of
397 Just res -> Just <$> execApp' (map (\(n, tm) -> (n, tm)) amap ++ env) ctxt res (drop arity args)
399 Just res -> Just <$> execApp' (map (\(n, tm) -> (n, tm)) amap ++ env) ctxt res (drop arity args)