Printing evaluation order
This commit is contained in:
parent
56c80faeff
commit
ee30b5db45
1 changed files with 10 additions and 4 deletions
|
|
@ -17,12 +17,18 @@ data Val where
|
||||||
VInt : Int -> Val
|
VInt : Int -> Val
|
||||||
VClos : Env -> Int -> Exp -> Val
|
VClos : Env -> Int -> Exp -> Val
|
||||||
|
|
||||||
data List a where
|
printExp : Exp -> Unit
|
||||||
Nil : List a
|
printExp exp = case exp of
|
||||||
Cons : a -> List a -> List a
|
EInt _ => printStr "EInt\n"
|
||||||
|
EAdd _ _ => printStr "EAdd\n"
|
||||||
|
EAbs _ _ => printStr "EAbs\n"
|
||||||
|
EApp _ _ => printStr "EApp\n"
|
||||||
|
EVar _ => printStr "EVar\n"
|
||||||
|
|
||||||
|
const x y = x
|
||||||
|
|
||||||
-- interp : Env -> Exp -> Val
|
-- interp : Env -> Exp -> Val
|
||||||
interp env exp = case exp of
|
interp env exp = case const exp (printExp exp) of
|
||||||
EInt i => VInt i
|
EInt i => VInt i
|
||||||
EAdd e1 e2 => case interp env e1 of
|
EAdd e1 e2 => case interp env e1 of
|
||||||
VInt i => case interp env e2 of
|
VInt i => case interp env e2 of
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue