#lang plait
(define-type BinOp [Plus] [Or])
(define-type Exp
[binE (operator : BinOp)
(left : Exp)
(right : Exp)]
[numE (value : Number)]
[boolE (value : Boolean)]
[ifE (check : Exp) (then-e : Exp) (else-e : Exp)])
(define-type Value [boolV (value : Boolean)] [numV (value : Number)])
(define (interp expr)
(type-case Exp expr
[(numE n) (numV n)]
[(boolE b) (boolV b)]
[(ifE check then-e else-e) ....]
[(binE o l r)
(let ([l-val (interp l)]
[r-val (interp r)])
(type-case BinOp o
[(Or) (boolV (or (boolV-value l-val) (boolV-value r-val)))]
[(Plus) (numV (+ (numV-value l-val) (numV-value r-val)))]))]))
(test (interp (binE (Plus) (numE 3) (numE 4)))
(numV 7))
(test (interp (binE (Or) (boolE #t) (boolE #f)))
(boolV #t))
(test (interp (ifE (boolE #f) (numE 1) (numE 2)))
(numV 2))