Improve printing of effects for functions with simple effects.

Reject contract creation of overloaded types.

svn: r12105
This commit is contained in:
Sam Tobin-Hochstadt 2008-10-23 21:43:23 +00:00
parent 9aab8ed8c8
commit ae1fd58e2b
2 changed files with 11 additions and 2 deletions

View File

@ -18,6 +18,7 @@
syntax/struct syntax/struct
syntax/stx syntax/stx
mzlib/trace mzlib/trace
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 scheme/contract (only-in scheme/class object% is-a?/c subclass?/c))) (for-template scheme/base scheme/contract (only-in scheme/class object% is-a?/c subclass?/c)))
@ -40,6 +41,9 @@
(generate-contract-def e))) (generate-contract-def e)))
(syntax->list forms))) (syntax->list forms)))
(define (no-duplicates l)
(= (length l) (length (remove-duplicates l))))
(define (type->contract ty fail) (define (type->contract ty fail)
(define vars (make-parameter '())) (define vars (make-parameter '()))
@ -97,6 +101,9 @@
(if rst (if rst
#'((dom* ...) () #:rest (listof rst*) . ->* . rng*) #'((dom* ...) () #:rest (listof rst*) . ->* . rng*)
#'(dom* ... . -> . rng*)))) #'(dom* ... . -> . rng*))))
(unless (no-duplicates (for/list ([t arrs])
(match t [(arr: dom _ _ _ _ _ _) (length dom)])))
(exit (fail)))
(match (map f arrs) (match (map f arrs)
[(list e) e] [(list e) e]
[l #`(case-> #,@l)]))] [l #`(case-> #,@l)]))]

View File

@ -64,8 +64,10 @@
(when drest (when drest
(fp "~a ... ~a " (car drest) (cdr drest))) (fp "~a ... ~a " (car drest) (cdr drest)))
(fp "-> ~a" rng) (fp "-> ~a" rng)
(unless (and (null? thn-eff) (null? els-eff)) (match* (thn-eff els-eff)
(fp " : ~a ~a" thn-eff els-eff)) [((list) (list)) (void)]
[((list (Latent-Restrict-Effect: t)) (list (Latent-Remove-Effect: t))) (fp " : ~a" t)]
[(_ _) (fp " : ~a ~a" thn-eff els-eff)])
(fp ")")])) (fp ")")]))
(define (tuple? t) (define (tuple? t)
(match t (match t