Type-Checking Impl for add-exp
(define value-of (define type-of
(lambda (exp env) (lambda (exp tenv)
(cases expression exp (cases expression exp
(add-exp (exp1 exp2) (add-exp (exp1 exp2)
(let ((val1 (value-of exp1 env)) (let ((ty1 (type-of exp1 tenv)
(val2 (value-of exp2 env))) → (ty2 (type-of exp2 tenv)))
(let ((num1 (expval->num val1)) (check-equal-type! ty1 (int-type))
(num2 (expval->num val2))) (check-equal-type! ty2 (int-type))
(num-val (+ num1 num2))))))) (int-type)))
...) ...)
(define check-equal-type!
(lambda (ty1 ty2)
(when (not (equal? ty1 ty2))
(report-unequal-types ty1 ty2))))