Skip to content

Commit 9ba7700

Browse files
committed
Fixed scoped foralls, but types are being re-expanded
1 parent 8505f6e commit 9ba7700

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

hackett-lib/hackett/private/base.rkt

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -327,26 +327,30 @@
327327

328328
(begin-for-syntax
329329
; fixity : [Maybe Fixity]
330-
(struct val-decl [internal-id type exact? fixity]
330+
(struct val-decl [internal-id
331+
type
332+
type-unexpanded
333+
exact?
334+
fixity]
331335
#:property prop:procedure
332336
(λ (this stx)
333-
(match-define (val-decl x- type _ _) this)
337+
(match-define (val-decl x- type _ _ _) this)
334338
((make-typed-var-transformer x- type) stx))
335339
#:property prop:infix-operator
336340
(λ (this) (val-decl-fixity this)))
337341

338342
(define-syntax-class id/val-decl
339343
#:attributes [internal-id
340-
type.expansion type.scoped-binding-introducer
344+
type-unexpanded
341345
exact?
342346
fixity]
343347
[pattern (~var x (local-value val-decl?))
344-
#:do [(match-define (val-decl x-* type* exact?* fixity*)
348+
#:do [(match-define (val-decl x-* _ type* exact?* fixity*)
345349
(attribute x.local-value))]
346-
#:attr internal-id (syntax-local-introduce x-*)
347-
#:with type:type (syntax-local-introduce type*)
348-
#:attr exact? exact?*
349-
#:attr fixity fixity*]))
350+
#:attr internal-id (syntax-local-introduce x-*)
351+
#:with type-unexpanded (syntax-local-introduce type*)
352+
#:attr exact? exact?*
353+
#:attr fixity fixity*]))
350354

351355
;; ---------------------------------------------------------------------------------------------------
352356

@@ -397,22 +401,23 @@
397401
; will be understood by `def`.
398402
[_
399403
(syntax-parse stx
400-
[(_ x:id {~type t:type}
404+
[(_ x:id t_unexpanded:expr
401405
{~alt {~optional {~and #:exact exact?}}
402406
{~optional f:fixity-annotation}}
403407
...)
404408
#:with x- (generate-temporary #'x)
405409
#:with exct? (and (attribute exact?) #true)
406410
#:with fixity (attribute f.fixity)
411+
#:with {~type t:type} #'t_unexpanded
407412
#:with t_reduced (if (attribute exact?)
408413
#'t.expansion
409414
(type-reduce-context #'t.expansion))
410415
#'(define-syntax x
411-
(let-values ([() t.residual])
412-
(val-decl (quote-syntax x-)
413-
(quote-syntax t_reduced)
414-
'exct?
415-
'fixity)))])])))
416+
(val-decl (quote-syntax x-)
417+
(quote-syntax t_reduced)
418+
(quote-syntax t_unexpanded)
419+
'exct?
420+
'fixity))])])))
416421

417422
(define-syntax-parser λ1
418423
[(_ x:id e:expr)
@@ -441,11 +446,18 @@
441446
#:literals [:]
442447
[(_ x:id/val-decl e:expr)
443448
#:with x- #'x.internal-id
449+
#:with {~type t:type} #'x.type-unexpanded
450+
#:with t_reduced (if (attribute x.exact?)
451+
#'t.expansion
452+
(type-reduce-context #'t.expansion))
444453
(syntax-property
445-
#`(define- x- (: #,((attribute x.type.scoped-binding-introducer)
446-
#'e)
447-
x.type.expansion
448-
#:exact))
454+
#`(define- x-
455+
(let-values ([() t.residual])
456+
(#%expression
457+
(: #,((attribute t.scoped-binding-introducer)
458+
#'e)
459+
t_reduced
460+
#:exact))))
449461
'disappeared-use
450462
(syntax-local-introduce #'x))]
451463

0 commit comments

Comments
 (0)