diff options
author | JJ | 2024-07-16 01:17:18 +0000 |
---|---|---|
committer | JJ | 2024-07-16 01:17:18 +0000 |
commit | a8fa6eeb42fd0d119d3ce55f53c332da3df46db7 (patch) | |
tree | 347c070b7fa4bd6a55ea0c615b0ccb66fbed5f14 /stlc-let.rkt | |
parent | a5a6418813900441e846e6853711dff94d1f9406 (diff) |
backport check refactorings
Diffstat (limited to 'stlc-let.rkt')
-rw-r--r-- | stlc-let.rkt | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/stlc-let.rkt b/stlc-let.rkt index 3c4fef0..f906e48 100644 --- a/stlc-let.rkt +++ b/stlc-let.rkt @@ -22,18 +22,22 @@ (define (check expr with) (check-core (desugar expr) with #hash())) (define (check-core expr with Γ) - (match* (expr with) - [('sole 'Unit) #t] - [(n 'Nat) #:when (natural? n) #t] - [(x _) #:when (dict-has-key? Γ x) + (match with + ['sole (equal? 'Unit with)] + [n #:when (natural? n) (equal? 'Nat with)] + [x #:when (dict-has-key? Γ x) (equal? (dict-ref Γ x) with)] - [(`(λ (,x : ,t) ,e) `(,t1 → ,t2)) - (and (equal? t t1) (check-core e t2 (dict-set Γ x t1)))] - [(`(,e1 ,e2) t) + [`(λ (,x : ,t) ,e) + (match with + [`(,t1 → ,t2) + (and (equal? t1 t) (check-core e t2 (dict-set Γ x t1)))] + [_ #f])] + [`(,e1 ,e2) (match (infer-core e1 Γ) - [`(,t1 → ,t2) (and (equal? t2 t) (equal? t1 (infer-core e2 Γ)))] - [t #f])] - [(e t) #f])) + [`(,t1 → ,t2) + (and (equal? t2 with) (equal? t1 (infer-core e2 Γ)))] + [_ #f])] + [_ #f])) ;; (infer Expr Table[Sym, Type]): Type (define (infer expr) |