rewrote an ->d contract so that it would work with a let*-style scoping

This commit is contained in:
Robby Findler 2010-07-10 09:52:47 -05:00
parent 476dd36eec
commit 41cfcbe862

View File

@ -3,11 +3,9 @@
(require scheme/match scheme/contract) (require scheme/match scheme/contract)
(require "rep-utils.rkt" "free-variance.rkt") (require "rep-utils.rkt" "free-variance.rkt")
(define Filter/c (define (Filter/c-predicate? e)
(flat-named-contract (and (Filter? e) (not (NoFilter? e)) (not (FilterSet? e))))
'Filter (define Filter/c (flat-named-contract 'Filter Filter/c-predicate?))
(λ (e)
(and (Filter? e) (not (NoFilter? e)) (not (FilterSet? e))))))
(define FilterSet/c (define FilterSet/c
(flat-named-contract (flat-named-contract
@ -48,17 +46,16 @@
(combine-frees (map free-idxs* fs))]) (combine-frees (map free-idxs* fs))])
(df FilterSet (thn els) (df FilterSet (thn els)
[#:contract (->d ([t (cond [(Bot? t) [#:contract (->d ([t any/c]
Bot?] [e any/c])
[(Bot? e)
Top?]
[else Filter/c])]
[e (cond [(Bot? e)
Bot?]
[(Bot? t)
Top?]
[else Filter/c])])
(#:syntax [stx #f]) (#:syntax [stx #f])
#:pre-cond
(and (cond [(Bot? t) #t]
[(Bot? e) (Top? t)]
[else (Filter/c-predicate? t)])
(cond [(Bot? e) #t]
[(Bot? t) (Top? e)]
[else (Filter/c-predicate? e)]))
[result FilterSet?])] [result FilterSet?])]
[#:fold-rhs (*FilterSet (filter-rec-id thn) (filter-rec-id els))]) [#:fold-rhs (*FilterSet (filter-rec-id thn) (filter-rec-id els))])