Skip to content

Commit f5128a5

Browse files
capfredfsamth
authored andcommitted
full support for sequence types in for forms
fix #974
1 parent 64a4f42 commit f5128a5

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

typed-racket-lib/typed-racket/base-env/base-special-env.rkt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,24 @@
7878
(-> -Symbol -String (-> a -Boolean) (-> a -Nat) a -Nat (Un (-val #f) -Nat) -Nat (-values (list a -Index -Index -Index))))]
7979
;; make-sequence
8080
[(make-template-identifier 'make-sequence 'racket/private/for)
81-
(-poly (a b)
81+
(-polydots (a b)
8282
(let ([seq-vals
83-
(lambda (a)
83+
(lambda (a b)
8484
(-values (list
85-
(-> Univ (-values a))
85+
(-> Univ (-values-dots (list a) b 'b))
8686
(Un (-> Univ Univ) (-val #f))
8787
(-> Univ Univ)
8888
Univ
8989
(Un (-> Univ Univ) (-val #f))
90-
(Un (->* a Univ) (-val #f))
91-
(Un (->* (cons Univ a) Univ) (-val #f)))))])
90+
(Un (->... (list a) (b b) Univ) (-val #f))
91+
(Un (->... (list Univ a) (b b) Univ) (-val #f)))))])
9292
(cl->*
93-
(-> Univ -Byte (seq-vals (list -Byte)))
94-
(-> Univ -Index (seq-vals (list -Index)))
93+
(-> Univ -Byte (seq-vals -Byte b))
94+
(-> Univ -Index (seq-vals -Index b))
9595
;; Generous. Negative numbers aren't allowed.
96-
(-> Univ -Fixnum (seq-vals (list -NonNegFixnum)))
97-
(-> Univ -Int (seq-vals (list -Nat)))
98-
(-> Univ (-seq a) (seq-vals (list a)))
99-
(-> Univ (-seq a b) (seq-vals (list a b))))))]
96+
(-> Univ -Fixnum (seq-vals -NonNegFixnum b))
97+
(-> Univ -Int (seq-vals -Nat b))
98+
(->* (list Univ (-seq-dots (list a) b 'b)) (seq-vals a b)))))]
10099
;; check-range
101100
[(make-template-identifier 'check-range 'racket/private/for)
102101
(-> Univ Univ Univ -Void)]

typed-racket-lib/typed-racket/infer/infer-unit.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@
927927
[(? variance:co?) (i-subst null)]
928928
[(? variance:contra?) (i-subst/starred null Univ)]
929929
;; TODO figure out if there is a better subst here
930-
[(? variance:inv) (i-subst null)]))))
930+
[(? variance:inv?) (i-subst null)]))))
931931
S))
932932
(define (build-subst m)
933933
(match m

typed-racket-lib/typed-racket/typecheck/tc-app/tc-app-special.rkt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
[(tc-result1: (and t Poly?))
4949
(tc-expr/check #'quo (ret Univ))
5050
(tc/funapp #'op #'(quo arg)
51-
(instantiate-poly t (list-extend (list Univ Univ)
52-
i-anns
53-
Univ))
51+
(instantiate-poly t i-anns)
5452
(list (ret Univ) (single-value #'arg))
5553
expected)]))
5654
;; special-case for not - flip the props
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#lang typed/racket
2+
3+
(define-type In-Integer (-> (Listof (List Integer Number Float)) (Sequenceof Integer Number Float)))
4+
5+
(: test-int (-> In-Integer (Listof (List Integer Number Float)) Number))
6+
(define (test-int in-ints ints)
7+
(for/sum : Number ([([a : Integer] [b : Number] [c : Float]) (in-ints ints)])
8+
(+ a b c)))
9+
10+
(for/list : (Listof Integer) ([i : Integer (list 0 1)])
11+
(+ i 1))
12+
13+
(for/list : (Listof Integer) ([i : Integer (in-list (list 0 1))])
14+
(+ i 1))

0 commit comments

Comments
 (0)