Synthesize annotations for for/lists: if possible.

This commit is contained in:
Vincent St-Amour 2011-06-13 17:28:03 -04:00
parent f4973ff05e
commit 2922821f3c
2 changed files with 18 additions and 3 deletions

View File

@ -4,3 +4,7 @@
(define (f x)
(for/lists (#{y : (Listof Number)}) ([e (in-list x)])
e))
(for/lists: ([a : (Listof Number)])
([e (in-list '(1 2 3))])
e)

View File

@ -540,16 +540,27 @@ This file defines two sorts of primitives. All of them are provided into any mod
;; clauses with these 2.
(define-syntax (for/lists: stx)
(syntax-parse stx #:literals (:)
[(_ a:optional-standalone-annotation
[(_ : ty
((var:optionally-annotated-name) ...)
(clause:for-clause ...)
c:expr ...)
(maybe-annotate-body
(syntax-property
(quasisyntax/loc stx
(for/lists (var.ann-name ...)
(clause.expand ... ...)
c ...))
#'a.ty)]))
'type-ascription
#'ty)]
[(_ ((var:annotated-name) ...)
(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