aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJJ2024-06-15 01:02:16 +0000
committerJJ2024-06-15 02:24:01 +0000
commit694abf3dfe03f801acd5c3f542de5fe0893b9206 (patch)
tree7dd4ef037876c6170abed7c6ffd1aa0e45fec360
parentee6b2f04989a8d9aef9cbfb611840a2634e22f85 (diff)
lib: fix bug in desugaring match
-rw-r--r--lib.rkt27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib.rkt b/lib.rkt
index 8dca172..e2ccfcd 100644
--- a/lib.rkt
+++ b/lib.rkt
@@ -35,11 +35,11 @@
;; removes typing annotations
(define (strip expr)
(match expr
- [`(λ ,id (: ,type) ,body (: ,type)) `(λ ,(strip id) ,(strip body))]
- [`(λ ,id ,body (: ,type)) `(λ ,(strip id) ,(strip body))]
- [`(λ ,id (: ,type) ,body) `(λ ,(strip id) ,(strip body))]
- [`(,a ,b) `(,(strip a) ,(strip b))]
- [expr expr]))
+ [`(λ ,x (: ,t) ,e (: ,t)) `(λ ,(strip x) ,(strip e))]
+ [`(λ ,x ,e (: ,t)) `(λ ,(strip x) ,(strip e))]
+ [`(λ ,x (: ,t) ,e) `(λ ,(strip x) ,(strip e))]
+ [`(,e1 ,e2) `(,(strip e1) ,(strip e2))]
+ [e e]))
;; (fmt Expr) → String
(define (fmt expr)
@@ -71,17 +71,18 @@
['⟨⟩ 'sole]
[`(ref ,e) (desugar `(new ,e))]
[`(deref ,e) (desugar `(! ,e))]
+
[`(set ,e1 ,e2 ,in)
(desugar `(let _ (: Unit) (set ,e1 ,e2) ,in))]
+ [`(let ,id (: ,t) ,e)
+ (desugar `(let ,id (: ,t) ,e 'sole))]
- [`(let ,x (: (→ ,k ,a ,b)) (λ ,x ,e) ,in)
- (desugar `((λ ,x (: (→ ,k ,a ,b)) ,in) (λ ,x (: ,a) ,e)))]
- [`(let ,x (: (→ ,a ,b)) (λ ,x ,e) ,in)
- (desugar `((λ ,x (: (→ ,a ,b)) ,in) (λ ,x (: ,a) ,e)))]
- [`(let ,x (: ,t) ,e ,in)
- (desugar `((λ ,x (: ,t) ,in) ,e))]
- [`(let ,x (: ,t) ,e)
- (desugar `(let ,x (: ,t) ,e 'sole))]
+ [`(let ,id (: (→ ,k ,a ,b)) (λ ,x ,e) ,in)
+ (desugar `((λ ,id (: (→ ,k ,a ,b)) ,in) (λ ,x (: ,a) ,e)))]
+ [`(let ,id (: (→ ,a ,b)) (λ ,x ,e) ,in)
+ (desugar `((λ ,id (: (→ ,a ,b)) ,in) (λ ,x (: ,a) ,e)))]
+ [`(let ,id (: ,t) ,e ,in)
+ (desugar `((λ ,id (: ,t) ,in) ,e))]
[`(λ ,x (: ,t) ,e) `(λ ,x (: ,t) ,(desugar e))]
[`(,e1 ,e2 ,e3) `(,(desugar e1) ,(desugar e2) ,(desugar e3))]