Pass more tests
This commit is contained in:
parent
64eb62a4d7
commit
9a5a5d683f
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user