Handle Sequenceof in the type parser to support multiple values.

This commit is contained in:
Sam Tobin-Hochstadt 2015-12-15 20:29:58 -05:00
parent ad88f45bbe
commit 519dfb6fdc
5 changed files with 8 additions and 2 deletions

View File

@ -17,7 +17,7 @@
(define-other-types
-> ->* case-> U Rec All Opaque Vector
Parameterof List List* Class Object Unit Values AnyValues Instance Refinement
pred Struct Struct-Type Prefab Top Bot Distinction)
pred Struct Struct-Type Prefab Top Bot Distinction Sequenceof)
(provide (rename-out [All ]
[U Un]

View File

@ -187,7 +187,6 @@
[Pairof (-poly (a b) (-pair a b))]
[MPairof (-poly (a b) (-mpair a b))]
[MListof (-poly (a) (-mlst a))]
[Sequenceof (-poly (a) (-seq a))]
[Thread-Cellof (-poly (a) (-thread-cell a))]
[Custodian-Boxof (-poly (a) (make-CustodianBox a))]

View File

@ -108,6 +108,7 @@
(define-literal-syntax-class #:for-label Top)
(define-literal-syntax-class #:for-label Bot)
(define-literal-syntax-class #:for-label Distinction)
(define-literal-syntax-class #:for-label Sequenceof)
;; (Syntax -> Type) -> Syntax Any -> Syntax
;; See `parse-type/id`. This is a curried generalization.
@ -483,6 +484,8 @@
#:stx stx
(~a (syntax-e #'p) " expects one or two type arguments, given "
(sub1 (length (syntax->list #'(args ...))))))]
[(:Sequenceof^ t ...)
(apply -seq (parse-types #'(t ...)))]
;; curried function notation
[((~and dom:non-keyword-ty (~not :->^)) ...
:->^

View File

@ -402,6 +402,7 @@
[FAIL (Unit (init-depend) String)]
[FAIL (Unit (import bad) (export) String)]
[FAIL (Unit (import) (export bad) String)]
[(Sequenceof Any Any) (-seq Univ Univ)]
))
;; FIXME - add tests for parse-values-type, parse-tc-results

View File

@ -3835,6 +3835,9 @@
[tc-e (for*/fold: ((xs : (Listof Symbol) '())) ((x '(a b c)))
(cons x xs))
(-lst -Symbol)]
[tc-e (ann (in-hash (hash)) (Sequenceof Any Any))
(-seq Univ Univ)]
)
(test-suite