Add contract generation for Set type.

This commit is contained in:
Sam Tobin-Hochstadt 2011-05-15 21:55:04 -04:00
parent 7b3039d22d
commit e92af62ca0
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,7 @@
#lang typed/racket
(define-predicate string-set? (Setof String))
(string-set? (set 1 2 3))
(string-set? (set "1" "2" "3"))

View File

@ -14,7 +14,7 @@
(private parse-type)
racket/match unstable/match syntax/struct syntax/stx mzlib/trace racket/syntax scheme/list
(only-in scheme/contract -> ->* case-> cons/c flat-rec-contract provide/contract any/c)
(for-template scheme/base racket/contract (utils any-wrap)
(for-template scheme/base racket/contract racket/set (utils any-wrap)
(prefix-in t: (types numeric-predicates))
(only-in scheme/class object% is-a?/c subclass?/c object-contract class/c init object/c class?)))
@ -184,6 +184,7 @@
([cnts (append (map t->c vars) (map t->c notvars))])
#'(or/c . cnts)))]
[(and t (Function: _)) (t->c/fun t)]
[(Set: t) #`(set/c #,(t->c t))]
[(Vector: t)
(if flat?
#`(vectorof #,(t->c t #:flat #t) #:flat? #t)