Skip to content

Commit adcc138

Browse files
authored
type for the optional arguments of 'in-fx/fl/extflvector' (#953)
1 parent b08a58a commit adcc138

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@
7474
;; unsafe-normalise-inputs
7575
[(make-template-identifier 'unsafe-normalise-inputs 'racket/private/for)
7676
(-poly (a)
77-
(-> (-> a -Nat) a -Nat (Un (-val #f) -Nat) -Nat (-values (list a -Index -Index -Index))))]
77+
(-> (-> a -Nat) a -Nat (Un (-val #f) -Int) -Int (-values (list a -Index -Index -Index))))]
7878
;; normalise-inputs
7979
[(make-template-identifier 'normalise-inputs 'racket/private/for)
8080
(-poly (a)
81-
(-> -Symbol -String (-> a -Boolean) (-> a -Nat) a -Nat (Un (-val #f) -Nat) -Nat (-values (list a -Index -Index -Index))))]
81+
(-> -Symbol -String (-> a -Boolean) (-> a -Nat) a -Nat (Un (-val #f) -Int) -Int (-values (list a -Index -Index -Index))))]
8282
;; make-sequence
8383
[(make-template-identifier 'make-sequence 'racket/private/for)
8484
(-polydots (a b)
@@ -366,11 +366,11 @@
366366
(-> -Variable-Reference -Module-Path -Resolved-Module-Path)]
367367
;; in-fxvector, in-flvector, in-extflvector
368368
[(make-template-identifier 'in-fxvector* 'racket/fixnum)
369-
(-> -FxVector (-seq -Fixnum))]
369+
(->opt -FxVector [-Int (-opt -Int) -Int] (-seq -Fixnum))]
370370
[(make-template-identifier 'in-flvector* 'racket/flonum)
371-
(-> -FlVector (-seq -Flonum))]
371+
(->opt -FlVector [-Int (-opt -Int) -Int] (-seq -Flonum))]
372372
[(make-template-identifier 'in-extflvector* 'racket/extflonum)
373-
(-> -ExtFlVector (-seq -ExtFlonum))]
373+
(->opt -ExtFlVector [-Int (-opt -Int) -Int] (-seq -ExtFlonum))]
374374
[(make-template-identifier 'make-namespace-anchor 'racket/private/namespace)
375375
(-> -Variable-Reference -Namespace-Anchor)]
376376
[(make-template-identifier 'check-logger-or-false 'racket/private/logger)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#lang typed/racket/base
2+
3+
(require racket/sequence
4+
racket/flonum
5+
racket/fixnum
6+
racket/extflonum
7+
typed/rackunit)
8+
9+
(check-equal? (sequence->list (in-flvector (flvector 1.0 2.0 3.0 4.0))) (list 1.0 2.0 3.0 4.0))
10+
(check-equal? (sequence->list (in-flvector (flvector 1.0 2.0 3.0 4.0) 1)) (list 2.0 3.0 4.0))
11+
(check-equal? (sequence->list (in-flvector (flvector 1.0 2.0 3.0 4.0) 1 2)) (list 2.0))
12+
(check-equal? (sequence->list (in-flvector (flvector 1.0 2.0 3.0 4.0) 0 #f 2)) (list 1.0 3.0))
13+
(check-equal? (for/list : (Listof Flonum) ([i (in-flvector (flvector 1.0 2.0 3.0 4.0) 3 -1 -2)]) i)
14+
(list 4.0 2.0))
15+
16+
(check-equal? (sequence->list (in-fxvector (fxvector 1 2 3 4) 0 #f 2)) (list 1 3))
17+
(check-equal? (for/list : (Listof Fixnum) ([i : Fixnum (ann (in-fxvector (fxvector 1 2 3 4) 3 -1 -2) (Sequenceof Fixnum))]) i)
18+
(list 4 2))
19+
;; I don't understand why this fails...
20+
#;(check-equal? (for/list : (Listof Fixnum) ([i (in-fxvector (fxvector 1 2 3 4) 3 -1 -2)]) i)
21+
(list 4 2))
22+
23+
(when (extflonum-available?)
24+
(check-equal? (for/list : (Listof ExtFlonum) ([i (in-extflvector (extflvector 1.0t0 2.0t0 3.0t0 4.0t0) 3 -1 -2)]) i)
25+
(list 4.0t0 2.0t0)))

0 commit comments

Comments
 (0)