aboutsummaryrefslogtreecommitdiff
path: root/stlc.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'stlc.rkt')
-rw-r--r--stlc.rkt10
1 files changed, 2 insertions, 8 deletions
diff --git a/stlc.rkt b/stlc.rkt
index 706557d..820197b 100644
--- a/stlc.rkt
+++ b/stlc.rkt
@@ -19,23 +19,17 @@
;; (check Expr Type Table[Sym, Type]): Bool
(define (check expr with [Γ #hash()])
(match expr
- [x #:when (dict-has-key? Γ x)
- (equal? (dict-ref Γ x) with)]
[`(λ (,x : ,t) ,e)
(match with
[`(,t1 → ,t2)
(and (equal? t t1) (check e t2 (dict-set Γ x)))]
[_ #f])]
- [`(,e1 ,e2)
- (match (infer e1 Γ)
- [`(,t1 → ,t2)
- (and (equal? t2 with) (equal? t1 (infer e2 Γ)))]
- [_ #f])]
- [_ #f]))
+ [_ (equal? (infer with Γ) with)]))
;; (infer Expr Table[Sym, Type]): Type
(define (infer expr [Γ #hash()])
(match expr
+ [x #:when (dict-has-key? Γ x) (dict-ref Γ x)]
[`(λ (,x : ,t) ,e)
`(,t → ,(infer e (dict-set Γ x t)))]
[`(,e1 ,e2)