Skip to content

Commit 35bc7d8

Browse files
Fix 1 occurrence of for/fold-result-keyword
Only one of the `for/fold` expression's result values is used. Use the `#:result` keyword to return just that result.
1 parent 8ed0ce0 commit 35bc7d8

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

typed-racket-lib/typed-racket/types/printer.rkt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -322,30 +322,30 @@
322322
(let loop ([to-cover coverable]
323323
[candidates candidates]
324324
[coverage '()])
325-
(cond [(null? to-cover) ; done
326-
(define coverage-names (map car coverage))
327-
;; to allow :type to cue the user on unexpanded aliases
328-
;; only union types can flow here, and any of those could be expanded
329-
(set-box! (current-print-unexpanded)
330-
(append coverage-names (unbox (current-print-unexpanded))))
331-
;; reverse here to retain the old ordering from when srfi/1 was
332-
;; used to process the list sets
333-
(values coverage-names (reverse uncoverable))] ; we want the names
334-
[else
335-
;; pick the candidate that covers the most uncovered types
336-
(define (covers-how-many? c)
337-
(length (set-intersect (cdr c) to-cover)))
338-
(define-values (next _)
339-
(for/fold ([next (car candidates)]
340-
[max-cover (covers-how-many? (car candidates))])
341-
([c (in-list candidates)])
342-
(let ([how-many? (covers-how-many? c)])
343-
(if (> how-many? max-cover)
344-
(values c how-many?)
345-
(values next max-cover)))))
346-
(loop (set-subtract to-cover (cdr next))
347-
(remove next candidates)
348-
(cons next coverage))])))
325+
(cond
326+
[(null? to-cover) ; done
327+
(define coverage-names (map car coverage))
328+
;; to allow :type to cue the user on unexpanded aliases
329+
;; only union types can flow here, and any of those could be expanded
330+
(set-box! (current-print-unexpanded)
331+
(append coverage-names (unbox (current-print-unexpanded))))
332+
;; reverse here to retain the old ordering from when srfi/1 was
333+
;; used to process the list sets
334+
(values coverage-names (reverse uncoverable))] ; we want the names
335+
[else
336+
;; pick the candidate that covers the most uncovered types
337+
(define (covers-how-many? c)
338+
(length (set-intersect (cdr c) to-cover)))
339+
(define next
340+
(for/fold ([next (car candidates)]
341+
[max-cover (covers-how-many? (car candidates))]
342+
#:result next)
343+
([c (in-list candidates)])
344+
(let ([how-many? (covers-how-many? c)])
345+
(if (> how-many? max-cover)
346+
(values c how-many?)
347+
(values next max-cover)))))
348+
(loop (set-subtract to-cover (cdr next)) (remove next candidates) (cons next coverage))])))
349349

350350
;; arr->sexp : arr -> s-expression
351351
;; Convert an arr (see type-rep.rkt) to its printable form

0 commit comments

Comments
 (0)