|
157 | 157 | (syntax-track-origin #'t-.residual #'head) |
158 | 158 | (syntax-track-origin #'expansion #'head))] |
159 | 159 | [pattern (head:#%type:qual ~! {~var a (type intdef-ctx)} {~var b (type intdef-ctx)}) |
160 | | - #:attr expansion (syntax/loc/props this-syntax |
161 | | - (head a.expansion b.expansion)) |
| 160 | + #:do [(define outer-this-syntax this-syntax)] |
| 161 | + ; There’s never really any reason to have a #%type:forall immediately inside a |
| 162 | + ; #%type:qual, and users don’t expect to see such types, so push #%type:qual down when it |
| 163 | + ; appears immediately around a #%type:forall. |
| 164 | + #:attr expansion (syntax-parse #'b.expansion |
| 165 | + [(~#%type:forall* [x ...+] t) |
| 166 | + (quasisyntax/loc/props this-syntax |
| 167 | + (?#%type:forall* [x ...] #,(syntax/loc/props outer-this-syntax |
| 168 | + (head a.expansion t))))] |
| 169 | + [_ (syntax/loc/props outer-this-syntax |
| 170 | + (head a.expansion b.expansion))]) |
162 | 171 | #:attr scoped-binding-ctxs '() |
163 | 172 | #:attr residual (~> #'(values) |
164 | 173 | (syntax-track-origin #'a.residual #'head) |
|
187 | 196 | (define (expand-type stx [intdef-ctx #f]) |
188 | 197 | (syntax-parse stx |
189 | 198 | #:context 'expand-type |
190 | | - [{~var t (type intdef-ctx)} #'t.expansion]))) |
| 199 | + [{~var t (type intdef-ctx)} #'t.expansion])) |
191 | 200 |
|
192 | 201 | ;; --------------------------------------------------------------------------------------------------- |
193 | 202 | ;; helper expanders / metafunctions |
|
199 | 208 | ; {?#%type:app Either String Integer}. Similar helpers are provided for nested foralls and nested |
200 | 209 | ; qualifications. |
201 | 210 |
|
202 | | -(begin-for-syntax |
203 | 211 | (define-syntax-class nested-apps |
204 | 212 | #:description #f |
205 | 213 | #:attributes [[linearized 1]] |
|
0 commit comments