generated from jackfirth/racket-package-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
good first issueGood for newcomersGood for newcomersnew lintIssues suggesting new lints or pull requests implementing new lintsIssues suggesting new lints or pull requests implementing new lints
Description
Saw a few cases in racket/typed-racket#1410 where #:when would clean up various bits of pattern matching code:
#lang resyntax/test
test: "original code should be refactorable to new code"
--------------------
#lang racket
(define (f pt)
(match pt
[(list x y)
(if (> x y)
(list y x)
pt)]
[(list) '()]))
--------------------
--------------------
#lang racket
(define (f pt)
(match pt
[(list x y)
#:when (> x y)
(list y x)]
[(list x y) pt]
[(list) '()]))
--------------------This should probably only trigger when the pattern is small. It should also only trigger on match expressions that already have multiple branches, since the single-branch case would be clearer as a match-define. A two-case cond instead of an if should also count.
Copilot
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersnew lintIssues suggesting new lints or pull requests implementing new lintsIssues suggesting new lints or pull requests implementing new lints