From 9a5a5d683ffd79f777333dac67c26e3741cafd4c Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Wed, 26 Mar 2025 14:26:41 -0300 Subject: [PATCH] Pass more tests --- Assignments/02.rkt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Assignments/02.rkt b/Assignments/02.rkt index 2661959..f19f310 100644 --- a/Assignments/02.rkt +++ b/Assignments/02.rkt @@ -119,14 +119,16 @@ [(leqE l r) (num2 l r (boolT))] [(varE s) (type-lookup s env)] [(lamE name te body) (arrowT (interp-te te) (typecheck body (type-extend env name (interp-te te))))] - [(appE fn arg) (typecheck fn env)] ; add proper handling for non functions + [(appE fn arg) (type-case Type (typecheck fn env) + [(arrowT a b) (typecheck fn env)] + [else (error 'app "Function application must be a function")])] [(ifE c t f) (if (equal? (typecheck c env) (boolT)) (if (equal? (typecheck t env) (typecheck f env)) (typecheck t env) (error 'if "Both if conditions must be of the same type")) (error 'if "Condition must be a boolean expression"))] - [(let1E var te val body) (arrowT (interp-te te) (typecheck body (type-extend env var (interp-te te))))] ; should be more returning type of lam, should just handle errors from application - [(recE var te val body) (typecheck body env)] ; add type binding for rec for use within same function, should be similar to let + [(let1E var te val body) (typecheck body (type-extend env var (interp-te te)))] + [(recE var te val body) (typecheck body (type-extend env var (interp-te te)))] ; figure out https://www.cs.unb.ca/~bremner/teaching/cs4613/docs/plai-3.2.2.pdf#page=132 ))) (tc : (S-Exp -> Type))