Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elimnators and lambda not resugared properly? #132

Open
wilbowma opened this issue Jun 22, 2020 · 1 comment
Open

Elimnators and lambda not resugared properly? #132

wilbowma opened this issue Jun 22, 2020 · 1 comment

Comments

@wilbowma
Copy link
Owner

#lang cur
(require
 (only-in cur [new-elim elim]))

(define-datatype Nat : Type
  (z : Nat)
  (s : (-> Nat Nat)))

(begin-for-syntax
  (displayln (cur-reflect
              (cur-expand
               #`(lambda (x : Nat)
                   (elim
                    x
                    (lambda (x : Nat) Nat)
                    z
                    (lambda (n : Nat) (IH : Nat) n)))))))

> #<syntax (λ (x) (elim-Nat x (λ (X10) Nat) (z) (λ (X1) (λ (X11) X1))))>
> #<syntax (λ (x) (elim-Nat x (λ (X1) Nat) (z) (λ (X1) (λ (X2) X1))))>
> 
> #<syntax (λ (x) (elim-Nat x (λ (X10) Nat) (z) (λ (X1) (λ (X11) X1))))>
> #<syntax (λ (x) (elim-Nat x (λ (X1) Nat) (z) (λ (X1) (λ (X2) X1))))>

I expected elim to resugar to elim, rather than elim-Nat. This isn't a huge deal. But also, the lambdas inside the elim ought to have type annotations. That one does reduce readability.

@stchang
Copy link
Collaborator

stchang commented Jun 23, 2020

Yes, right now a term expanded from a general elim is indistinguishable from a type specific one.

Same with expanded lambda, it doesnt know if the original term had an annotation or not. A quick fix would be to just add more stx props. But a better way would be to have terms also implement the "type info" that types have (which includes a resugar method for each term).

We'd have to modify Turnstile to have define-typed-syntax do everything that define-type does which could be a substantial change though. I'll need to think about what the syntax of that new define-typed-syntax would look like though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants