From 82050c3b4025bbfe4bd41bf8bcb166a5ea1d7d57 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Mon, 24 Mar 2014 00:09:17 -0700 Subject: [PATCH] Make -filter and -not-filter do more simplification. original commit: cc377272d666d709687ce330eadad822619d7d84 --- .../typed-racket/types/base-abbrev.rkt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/base-abbrev.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/base-abbrev.rkt index bf3a04a2..0cbbabf6 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/base-abbrev.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/base-abbrev.rkt @@ -123,18 +123,24 @@ (define/cond-contract (-filter t i [p null]) (c:->* (Type/c (c:or/c integer? name-ref/c)) ((c:listof PathElem?)) Filter/c) (define i* (if (integer? i) (list 0 i) i)) - (if (or (type-equal? Univ t) (and (identifier? i) (is-var-mutated? i))) - -top - (make-TypeFilter t p i*))) + (cond + [(and (identifier? i) (is-var-mutated? i)) -top] + [(equal? Univ t) -top] + [(equal? -Bottom t) -bot] + [else (make-TypeFilter t p i*)])) + ;; Abbreviation for not filters ;; `i` can be an integer for backwards compatibility (define/cond-contract (-not-filter t i [p null]) (c:->* (Type/c (c:or/c integer? name-ref/c)) ((c:listof PathElem?)) Filter/c) (define i* (if (integer? i) (list 0 i) i)) - (if (or (type-equal? -Bottom t) (and (identifier? i) (is-var-mutated? i))) - -top - (make-NotTypeFilter t p i*))) + (cond + [(and (identifier? i) (is-var-mutated? i)) -top] + [(equal? -Bottom t) -top] + [(equal? Univ t) -bot] + [else (make-NotTypeFilter t p i*)])) + (define (-filter-at t o) (match o