From a431e7b5c7f16453e34808b8444f3bf937dad1d7 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Wed, 15 Jun 2011 17:01:49 -0400 Subject: [PATCH] Add contracts for `Sequenceof' values. original commit: eaa156554a5c5305d147371bec0619436a0e7993 --- collects/tests/typed-scheme/succeed/sequence-cnt.rkt | 12 ++++++++++++ collects/typed-scheme/private/type-contract.rkt | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 collects/tests/typed-scheme/succeed/sequence-cnt.rkt diff --git a/collects/tests/typed-scheme/succeed/sequence-cnt.rkt b/collects/tests/typed-scheme/succeed/sequence-cnt.rkt new file mode 100644 index 00000000..d77c9dac --- /dev/null +++ b/collects/tests/typed-scheme/succeed/sequence-cnt.rkt @@ -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) \ No newline at end of file diff --git a/collects/typed-scheme/private/type-contract.rkt b/collects/typed-scheme/private/type-contract.rkt index cc6ee54f..d9f5331d 100644 --- a/collects/typed-scheme/private/type-contract.rkt +++ b/collects/typed-scheme/private/type-contract.rkt @@ -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)