Make Typed Racket name printing more deterministic.

This commit is contained in:
Sam Tobin-Hochstadt 2012-10-28 13:55:02 -04:00
parent cdf7cad8ac
commit 5861bf0b9f

View File

@ -36,10 +36,16 @@
;; does t have a type name associated with it currently? ;; does t have a type name associated with it currently?
;; has-name : Type -> Maybe[Symbol] ;; has-name : Type -> Maybe[Symbol]
(define (has-name? t) (define (has-name? t)
(and print-aliases (cond
(for/first ([(n t*) (in-pairs (in-list (force (current-type-names))))] [print-aliases
(define candidates
(for/list ([(n t*) (in-pairs (in-list (force (current-type-names))))]
#:when (and (Type? t*) (type-equal? t t*))) #:when (and (Type? t*) (type-equal? t t*)))
n))) n))
(if (null? candidates)
#f
(car (sort candidates string>? #:key symbol->string)))]
[else #f]))
(define (print-filter c port write?) (define (print-filter c port write?)
(define (fp . args) (apply fprintf port args)) (define (fp . args) (apply fprintf port args))