From deb336738c9126ba2681aa78ae92a93d77bef5ef Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Tue, 5 Feb 2013 09:13:03 -0800 Subject: [PATCH] Minor cleanup in subtype.rkt original commit: b9c4582746524c1063564ad306194fd0ba4069a0 --- collects/typed-racket/types/subtype.rkt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/collects/typed-racket/types/subtype.rkt b/collects/typed-racket/types/subtype.rkt index 87c0ab86..a8d32dd9 100644 --- a/collects/typed-racket/types/subtype.rkt +++ b/collects/typed-racket/types/subtype.rkt @@ -53,7 +53,7 @@ ;; are all the s's subtypes of all the t's? ;; [type] [type] -> boolean -(define (subtypes s t) (handle-failure (subtypes* (current-seen) s t))) +(define (subtypes s t) (handle-failure (and (subtypes* (current-seen) s t) #t))) ;; subtyping under constraint set, but produces boolean result instead of raising exn ;; List[(cons Number Number)] type type -> maybe[List[(cons Number Number)]] @@ -77,11 +77,11 @@ (define-syntax-class sub* (pattern e:expr)) (syntax-parse stx - [(_ init (s1:sub* . args1) (s:sub* . args) ...) - (with-syntax ([(A* ... A-last) (generate-temporaries #'(s1 s ...))]) + [(_ init (s:sub* . args) ...+) + (with-syntax ([(A* ... A-last) (generate-temporaries #'(s ...))]) (with-syntax ([(clauses ...) - (for/list ([s (syntax->list #'(s1 s ...))] - [args (syntax->list #'(args1 args ...))] + (for/list ([s (syntax->list #'(s ...))] + [args (syntax->list #'(args ...))] [A (syntax->list #'(init A* ...))] [A-next (syntax->list #'(A* ... A-last))]) #`[#,A-next (#,s #,A . #,args)])]) @@ -163,9 +163,7 @@ [(_ _) (fail! s t)])) (define (subtypes/varargs args dom rst) - (with-handlers - ([exn:subtype? (lambda _ #f)]) - (subtypes*/varargs null args dom rst))) + (handle-failure (and (subtypes*/varargs null args dom rst) #t))) (define (subtypes*/varargs A0 argtys dom rst) (let loop-varargs ([dom dom] [argtys argtys] [A A0]) @@ -560,9 +558,12 @@ (provide/cond-contract - [subtype (c:-> (c:or/c Type/c SomeValues/c) (c:or/c Type/c SomeValues/c) boolean?)]) -(provide - type-compare? subtypes/varargs subtypes) + [subtype (c:-> (c:or/c Type/c SomeValues/c) (c:or/c Type/c SomeValues/c) boolean?)] + [type-compare? (c:-> (c:or/c Type/c SomeValues/c) (c:or/c Type/c SomeValues/c) boolean?)] + [subtypes (c:-> (c:listof (c:or/c Type/c SomeValues/c)) + (c:listof (c:or/c Type/c SomeValues/c)) + boolean?)] + [subtypes/varargs (c:-> (c:listof Type/c) (c:listof Type/c) (c:or/c Type/c #f) boolean?)]) ;(require racket/trace) ;(trace subtype*)