From fa259393da45d7761f2e4fc908cc7a0d837f2641 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Sun, 28 Oct 2012 13:55:02 -0400 Subject: [PATCH] Make Typed Racket name printing more deterministic. original commit: 5861bf0b9fc5ff3b237619d02dc6d5eb4a55837e --- collects/typed-racket/types/printer.rkt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/collects/typed-racket/types/printer.rkt b/collects/typed-racket/types/printer.rkt index 20df7bda..41eaaf40 100644 --- a/collects/typed-racket/types/printer.rkt +++ b/collects/typed-racket/types/printer.rkt @@ -36,10 +36,16 @@ ;; does t have a type name associated with it currently? ;; has-name : Type -> Maybe[Symbol] (define (has-name? t) - (and print-aliases - (for/first ([(n t*) (in-pairs (in-list (force (current-type-names))))] - #:when (and (Type? t*) (type-equal? t t*))) - n))) + (cond + [print-aliases + (define candidates + (for/list ([(n t*) (in-pairs (in-list (force (current-type-names))))] + #:when (and (Type? t*) (type-equal? t t*))) + n)) + (if (null? candidates) + #f + (car (sort candidates string>? #:key symbol->string)))] + [else #f])) (define (print-filter c port write?) (define (fp . args) (apply fprintf port args))