stchang / macrotypes

BSD 2-Clause "Simplified" License
135 stars 14 forks source link

Cyclical Dependency: define-syntax-category <-> infer #48

Open iitalics opened 6 years ago

iitalics commented 6 years ago

There's a cyclical dependency between define-syntax-category and infer. The former defines functions like current-type-eval which are used by the latter. However, the type-generated forms of define-syntax-category, most prominently define-binding-type, make calls to infer when expanding kinds (or something like that).

Turnstile was able to get away with this because define-syntax-category would not define any binding types initially, then infer is defined, then user languages would call define-binding-type which would generate code to call infer. In trying to reduce syntax-parse-defining-macros, I moved the infer calls out of define-binding-type, which breaks.

I can solve this with a higher order function but that's clearly a patch, not a solution.

iitalics commented 6 years ago

here

stchang commented 6 years ago

What error do you get, unbound identifier? Shouldnt the lifted transformer function still be at the same phase as current-type-eval?

iitalics commented 6 years ago

Yes it's unbound identifier. Which on second thought doesn't make a lot of sense because expand/df resolves yet its defined below infers+ctx/erase. :man_shrugging:

However it does spit out a ton of scopes when attempting to use infers+ctx/erase:

macrotypes/typecheck.rkt:824:35: infers/ctx+erase: unbound identifier in module (in phase 1, transformer environment)
  context...:
   #(2136 module) #(2138 module typecheck 1) #(14047 macro) #(27743 local)
   #(27744 intdef) #(27752 local) #(27753 intdef) #(27755 local) #(27757 intdef)
   #(27761 local) #(27762 intdef) #(27766 local) #(27771 intdef) #(27772 local)
   #(27773 intdef) #(27777 local) #(27778 intdef) #(27781 local) #(27783 intdef)
...
...
   #(28234 intdef) #(28235 local) #(28236 intdef) #(28239 local) #(28241 intdef)
   #(28244 local) #(28246 intdef) #(28258 local) #(28259 intdef) #(28265 local)
   #(28272 intdef) #(28273 local) #(28274 intdef)

I'm not sure what this means. The scopes aren't printed if I use some other garbage identifier instead.

stchang commented 6 years ago

It seems type-error is affected as well.