Add contract generation for Set type.
This commit is contained in:
parent
7b3039d22d
commit
e92af62ca0
7
collects/tests/typed-scheme/succeed/set-contract.rkt
Normal file
7
collects/tests/typed-scheme/succeed/set-contract.rkt
Normal 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"))
|
|
@ -14,7 +14,7 @@
|
||||||
(private parse-type)
|
(private parse-type)
|
||||||
racket/match unstable/match syntax/struct syntax/stx mzlib/trace racket/syntax scheme/list
|
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)
|
(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))
|
(prefix-in t: (types numeric-predicates))
|
||||||
(only-in scheme/class object% is-a?/c subclass?/c object-contract class/c init object/c class?)))
|
(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))])
|
([cnts (append (map t->c vars) (map t->c notvars))])
|
||||||
#'(or/c . cnts)))]
|
#'(or/c . cnts)))]
|
||||||
[(and t (Function: _)) (t->c/fun t)]
|
[(and t (Function: _)) (t->c/fun t)]
|
||||||
|
[(Set: t) #`(set/c #,(t->c t))]
|
||||||
[(Vector: t)
|
[(Vector: t)
|
||||||
(if flat?
|
(if flat?
|
||||||
#`(vectorof #,(t->c t #:flat #t) #:flat? #t)
|
#`(vectorof #,(t->c t #:flat #t) #:flat? #t)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user