Make type annotations optional for for*/lists: and for*/fold:.
This commit is contained in:
parent
3ff1a3320a
commit
48bf6f8290
|
@ -625,22 +625,53 @@ This file defines two sorts of primitives. All of them are provided into any mod
|
||||||
(for*/vector: for*/vector)
|
(for*/vector: for*/vector)
|
||||||
(for*/flvector: for*/flvector))
|
(for*/flvector: for*/flvector))
|
||||||
|
|
||||||
(define-for-syntax (define-for*-folding-variant name)
|
;; Like for/lists: and for/fold:, the inferencer can handle these correctly.
|
||||||
(lambda (stx)
|
(define-syntax (for*/lists: stx)
|
||||||
(syntax-parse stx #:literals (:)
|
(syntax-parse stx #:literals (:)
|
||||||
[(_ : ty
|
[(_ : ty
|
||||||
(var ...)
|
((var:optionally-annotated-name) ...)
|
||||||
(clause:for*-clause ...)
|
(clause:for*-clause ...)
|
||||||
c:expr ...)
|
c:expr ...)
|
||||||
|
(syntax-property
|
||||||
(quasisyntax/loc stx
|
(quasisyntax/loc stx
|
||||||
(#,name : ty
|
(for/lists (var.ann-name ...)
|
||||||
(var ...)
|
|
||||||
(clause.expand ... ...)
|
(clause.expand ... ...)
|
||||||
c ...))])))
|
c ...))
|
||||||
|
'type-ascription
|
||||||
;; Like for/lists: and for/fold:, the inferencer can handle these correctly.
|
#'ty)]
|
||||||
(define-syntax for*/lists: (define-for*-folding-variant #'for/lists:))
|
[(_ ((var:annotated-name) ...)
|
||||||
(define-syntax for*/fold: (define-for*-folding-variant #'for/fold:))
|
(clause:for*-clause ...)
|
||||||
|
c:expr ...)
|
||||||
|
(syntax-property
|
||||||
|
(quasisyntax/loc stx
|
||||||
|
(for/lists (var.ann-name ...)
|
||||||
|
(clause.expand ... ...)
|
||||||
|
c ...))
|
||||||
|
'type-ascription
|
||||||
|
#'(values var.ty ...))]))
|
||||||
|
(define-syntax (for*/fold: stx)
|
||||||
|
(syntax-parse stx #:literals (:)
|
||||||
|
[(_ : ty
|
||||||
|
((var:optionally-annotated-name init:expr) ...)
|
||||||
|
(clause:for*-clause ...)
|
||||||
|
c:expr ...)
|
||||||
|
(syntax-property
|
||||||
|
(quasisyntax/loc stx
|
||||||
|
(for/fold ((var.ann-name init) ...)
|
||||||
|
(clause.expand ... ...)
|
||||||
|
c ...))
|
||||||
|
'type-ascription
|
||||||
|
#'ty)]
|
||||||
|
[(_ ((var:annotated-name init:expr) ...)
|
||||||
|
(clause:for*-clause ...)
|
||||||
|
c:expr ...)
|
||||||
|
(syntax-property
|
||||||
|
(quasisyntax/loc stx
|
||||||
|
(for/fold ((var.ann-name init) ...)
|
||||||
|
(clause.expand ... ...)
|
||||||
|
c ...))
|
||||||
|
'type-ascription
|
||||||
|
#'(values var.ty ...))]))
|
||||||
|
|
||||||
(define-syntax (provide: stx)
|
(define-syntax (provide: stx)
|
||||||
(syntax-parse stx
|
(syntax-parse stx
|
||||||
|
|
Loading…
Reference in New Issue
Block a user