Prohibit predicates, unions of tvars in contracts

Add vector?

svn: r15701
This commit is contained in:
Sam Tobin-Hochstadt 2009-08-11 19:35:34 +00:00
parent aae1fb9508
commit b23016f86a
2 changed files with 11 additions and 7 deletions

View File

@ -183,6 +183,7 @@
[- (cl->* (->* (list -Integer) -Integer -Integer) (->* (list N) N N))]
[max (->* (list N) N N)]
[min (->* (list N) N N)]
[vector? (make-pred-ty (-vec Univ))]
[vector-ref (-poly (a) ((-vec a) N . -> . a))]
[build-vector (-poly (a) (-Integer (-Integer . -> . a) . -> . (-vec a)))]
[build-list (-poly (a) (-Integer (-Integer . -> . a) . -> . (-lst a)))]

View File

@ -4,7 +4,7 @@
(require (except-in "../utils/utils.ss" extend))
(require
(rep type-rep)
(rep type-rep filter-rep object-rep)
(typecheck internal-forms)
(utils tc-utils require-contract)
(env type-name-env)
@ -65,18 +65,21 @@
[(Refinement: par p? cert)
#`(and/c #,(t->c par) (flat-contract #,(cert p?)))]
[(Union: elems)
(let-values ([(vars notvars)
(partition F? elems)])
(unless (>= 1 (length vars)) (exit (fail)))
(with-syntax
([cnts (map t->c elems)])
#;(printf "~a~n" (syntax-object->datum #'cnts))
#'(or/c . cnts))]
([cnts (append (map t->c vars) (map t->c notvars))])
#'(or/c . cnts)))]
[(Function: arrs)
(let ()
(define (f a)
(define-values (dom* rngs* rst)
(match a
[(arr: dom (Values: (list (Result: rngs _ _) ...)) rst #f '())
[(arr: dom (Values: (list (Result: rngs (LFilterSet: '() '()) (LEmpty:)) ...)) rst #f '())
(values (map t->c/neg dom) (map t->c rngs) (and rst (t->c/neg rst)))]
[_ (exit (fail))]))
(trace f)
(with-syntax
([(dom* ...) dom*]
[rng* (match rngs*