(define-type Binding
[binding (name symbol?) (named-expr CFWAE?)])
(define-type CFWAE
[num (n number?)]
[binop (op procedure?) (lhs CFWAE?) (rhs CFWAE?)]
[with (b Binding?) (body CFWAE?)]
[id (name symbol?)]
[if0 (c CFWAE?) (t CFWAE?) (e CFWAE?)]
[fun (arg symbol?) (body CFWAE?)]
[app (f CFWAE?) (arg CFWAE?)])
;; This may look new, but it is really just an
;; onion-core and an onion. Think about it.
(define-type Env
[mtEnv]
[anEnv (name symbol?) (value CFWAE-Value?) (env Env?)])
(define-type CFWAE-Value
[numV (n number?)]
[closureV (param symbol?)
(body CFWAE?)
(env Env?)])
;; parse : expression -> CFWAE
;; This procedure parses an expression into a CFWAE
(define (parse sexp)
...)
;; interp-with-env : CFWAE Env -> CFWAE-Value
(define (interp-with-env expr env)
...)
;; interp : CFWAE -> CFWAE-Value
;; This procedure interprets the given CFWAE and produces a result
;; in the form of a CFWAE-Value (either a closureV or a numV)
(define (interp expr)
(interp-with-env expr (mtEnv))