From ee30b5db4598aaf9d85fa6d0b8c081f2409ddc5e Mon Sep 17 00:00:00 2001 From: sebastianselander Date: Mon, 8 May 2023 22:08:59 +0200 Subject: [PATCH] Printing evaluation order --- sample-programs/lambda_calculus.crf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sample-programs/lambda_calculus.crf b/sample-programs/lambda_calculus.crf index cccbf2f..615d99c 100644 --- a/sample-programs/lambda_calculus.crf +++ b/sample-programs/lambda_calculus.crf @@ -17,12 +17,18 @@ data Val where VInt : Int -> Val VClos : Env -> Int -> Exp -> Val -data List a where - Nil : List a - Cons : a -> List a -> List a +printExp : Exp -> Unit +printExp exp = case exp of + 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 = case exp of +interp env exp = case const exp (printExp exp) of EInt i => VInt i EAdd e1 e2 => case interp env e1 of VInt i => case interp env e2 of