Add contracts for `Sequenceof' values.
original commit: eaa156554a5c5305d147371bec0619436a0e7993
This commit is contained in:
parent
c96832caba
commit
a431e7b5c7
12
collects/tests/typed-scheme/succeed/sequence-cnt.rkt
Normal file
12
collects/tests/typed-scheme/succeed/sequence-cnt.rkt
Normal file
|
@ -0,0 +1,12 @@
|
|||
#lang racket/load
|
||||
|
||||
(module m typed/racket
|
||||
(provide s)
|
||||
(: s (Sequenceof Integer))
|
||||
(define s (list 1 2 3)))
|
||||
|
||||
(module n racket
|
||||
(require 'm)
|
||||
(for ([i s]) (add1 i)))
|
||||
|
||||
(require 'n)
|
|
@ -16,6 +16,7 @@
|
|||
(only-in scheme/contract -> ->* case-> cons/c flat-rec-contract provide/contract any/c)
|
||||
(for-template scheme/base racket/contract racket/set (utils any-wrap)
|
||||
(prefix-in t: (types numeric-predicates))
|
||||
(only-in unstable/contract sequence/c)
|
||||
(only-in scheme/class object% is-a?/c subclass?/c object-contract class/c init object/c class?)))
|
||||
|
||||
(define (define/fixup-contract? stx)
|
||||
|
@ -185,6 +186,7 @@
|
|||
#'(or/c . cnts)))]
|
||||
[(and t (Function: _)) (t->c/fun t)]
|
||||
[(Set: t) #`(set/c #,(t->c t))]
|
||||
[(Sequence: ts) #`(sequence/c #,@(map t->c ts))]
|
||||
[(Vector: t)
|
||||
(if flat?
|
||||
#`(vectorof #,(t->c t #:flat #t) #:flat? #t)
|
||||
|
|
Loading…
Reference in New Issue
Block a user