-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated Resyntax fixes #1410
Automated Resyntax fixes #1410
Conversation
This is an automated change generated by Resyntax. #### Pass 1 Applied 1 fix to [`typed-racket-lib/typed-racket/types/tc-error.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/tc-error.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 10 fixes to [`typed-racket-lib/typed-racket/types/printer.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/printer.rkt) * Line 135, `quasiquote-to-list`: This quasiquotation is equialent to a simple `list` call. * Line 152, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 163, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 320, `define-values-values-to-define`: This use of `define-values` is unnecessary. * Line 327, `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. * Line 367, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 464, `apply-append-for-loop-to-for-loop`: Instead of using `(apply append ...)` to flatten a list of lists, consider using `for*/list` to flatten the list. * Line 480, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 515, `quasiquote-to-list`: This quasiquotation is equialent to a simple `list` call. * Line 519, `quasiquote-to-list`: This quasiquotation is equialent to a simple `list` call. Applied 2 fixes to [`typed-racket-lib/typed-racket/types/tc-result.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/tc-result.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 158, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 1 fix to [`typed-racket-lib/typed/private/no-check-helper.rkt`](../blob/HEAD/typed-racket-lib/typed/private/no-check-helper.rkt) * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 6 fixes to [`typed-racket-lib/typed-racket/types/base-abbrev.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/base-abbrev.rkt) * Line 105, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 109, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 496, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 502, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 509, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. * Line 516, `define-syntax-syntax-rules-to-define-syntax-rule`: This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro. Applied 3 fixes to [`typed-racket-test/external/tr-random-testing.rkt`](../blob/HEAD/typed-racket-test/external/tr-random-testing.rkt) * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 10, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 337, `if-begin-to-cond`: Using `cond` instead of `if` here makes `begin` unnecessary Applied 3 fixes to [`typed-racket-lib/typed-racket/types/signatures.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/signatures.rkt) * Line 6, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 52, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 59, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 1 fix to [`typed-racket-lib/typed-racket/types/struct-table.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/struct-table.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 3 fixes to [`typed-racket-lib/typed-racket/types/utils.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/utils.rkt) * Line 19, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 60, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 79, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 4 fixes to [`typed-racket-lib/typed-racket/types/prop-ops.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/prop-ops.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 56, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 111, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 382, `sort-with-keyed-comparator-to-sort-by-key`: This `sort` expression can be replaced with a simpler, equivalent expression. Applied 1 fix to [`typed-racket-lib/typed-racket/types/union.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/union.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 2 fixes to [`typed-racket-lib/typed-racket/types/generalize.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/generalize.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 48, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 1 fix to [`typed-racket-test/external/historical-counterexamples.rkt`](../blob/HEAD/typed-racket-test/external/historical-counterexamples.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/types/substitute.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/substitute.rkt) * Line 78, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting Applied 1 fix to [`typed-racket-lib/typed-racket/types/overlap.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/overlap.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 3 fixes to [`typed-racket-lib/typed-racket/types/subtype.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/subtype.rkt) * Line 536, `apply-flattening`: The `apply` function accepts single arguments in addition to a trailing list argument. * Line 661, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`. * Line 793, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 2 fixes to [`typed-racket-lib/typed/private/rewriter.rkt`](../blob/HEAD/typed-racket-lib/typed/private/rewriter.rkt) * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 10, `syntax-disarm-migration`: The `syntax-disarm` function is a legacy function that does nothing. Applied 2 fixes to [`typed-racket-lib/typed-racket/types/match-expanders.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/match-expanders.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 78, `define-simple-macro-to-define-syntax-parse-rule`: The `define-simple-macro` form has been renamed to `define-syntax-parse-rule`. Applied 3 fixes to [`typed-racket-lib/typed-racket/types/resolve.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/types/resolve.rkt) * Line 52, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`. * Line 65, `inverted-when`: This negated `when` expression can be replaced by an `unless` expression. * Line 101, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. ## Summary Fixed 50 issues in 19 files. * Fixed 14 occurrences of `tidy-require` * Fixed 7 occurrences of `single-clause-match-to-match-define` * Fixed 7 occurrences of `let-to-define` * Fixed 6 occurrences of `define-syntax-syntax-rules-to-define-syntax-rule` * Fixed 3 occurrences of `quasiquote-to-list` * Fixed 2 occurrences of `if-else-false-to-and` * Fixed 1 occurrence of `define-values-values-to-define` * Fixed 1 occurrence of `for/fold-result-keyword` * Fixed 1 occurrence of `apply-append-for-loop-to-for-loop` * Fixed 1 occurrence of `if-let-to-cond` * Fixed 1 occurrence of `apply-flattening` * Fixed 1 occurrence of `syntax-disarm-migration` * Fixed 1 occurrence of `define-simple-macro-to-define-syntax-parse-rule` * Fixed 1 occurrence of `inverted-when` * Fixed 1 occurrence of `if-begin-to-cond` * Fixed 1 occurrence of `define-lambda-to-define` * Fixed 1 occurrence of `sort-with-keyed-comparator-to-sort-by-key`
Bitten by jackfirth/resyntax#383 yet again. |
@@ -478,16 +476,15 @@ | |||
;; case-lambda->sexp : Type -> S-expression | |||
;; Convert a case-> type to an s-expression | |||
(define (case-lambda->sexp type) | |||
(match type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two matches could be combined which would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree, particularly since the third branch of the second match wants to refer to the arrows
variable anyway. This is how I'd write it:
(match-define (Fun: arrows) type)
(match arrows
[(list) '(case->)]
[(list a) (arr->sexp a)]
[(list a b ...)
(define cover (cover-case-lambda arrows))
(if (> (length cover) 1)
`(case-> ,@cover)
(car cover))])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I think I prefer:
(match type
[(Fun: (list)) '(case->)]
[(Fun: (list a)) (arr->sexp a)]
[(Fun: arrows)
(define cover (cover-case-lambda arrows))
(if (> (length cover) 1)
`(case-> ,@cover)
(car cover))])
but that might be hard to generate automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks quite reasonable. However, this all seems way too subjective for Resyntax to tackle.
This is an automated change generated by Resyntax.
Pass 1
Applied 1 fix to
typed-racket-lib/typed-racket/types/tc-error.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.Applied 10 fixes to
typed-racket-lib/typed-racket/types/printer.rkt
quasiquote-to-list
: This quasiquotation is equialent to a simplelist
call.single-clause-match-to-match-define
: Thismatch
expression can be simplified usingmatch-define
.single-clause-match-to-match-define
: Thismatch
expression can be simplified usingmatch-define
.define-values-values-to-define
: This use ofdefine-values
is unnecessary.for/fold-result-keyword
: Only one of thefor/fold
expression's result values is used. Use the#:result
keyword to return just that result.single-clause-match-to-match-define
: Thismatch
expression can be simplified usingmatch-define
.apply-append-for-loop-to-for-loop
: Instead of using(apply append ...)
to flatten a list of lists, consider usingfor*/list
to flatten the list.single-clause-match-to-match-define
: Thismatch
expression can be simplified usingmatch-define
.quasiquote-to-list
: This quasiquotation is equialent to a simplelist
call.quasiquote-to-list
: This quasiquotation is equialent to a simplelist
call.Applied 2 fixes to
typed-racket-lib/typed-racket/types/tc-result.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.single-clause-match-to-match-define
: Thismatch
expression can be simplified usingmatch-define
.Applied 1 fix to
typed-racket-lib/typed/private/no-check-helper.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.Applied 6 fixes to
typed-racket-lib/typed-racket/types/base-abbrev.rkt
define-syntax-syntax-rules-to-define-syntax-rule
: Thisdefine-syntax
macro can be replaced with a simpler, equivalentdefine-syntax-rule
macro.define-syntax-syntax-rules-to-define-syntax-rule
: Thisdefine-syntax
macro can be replaced with a simpler, equivalentdefine-syntax-rule
macro.define-syntax-syntax-rules-to-define-syntax-rule
: Thisdefine-syntax
macro can be replaced with a simpler, equivalentdefine-syntax-rule
macro.define-syntax-syntax-rules-to-define-syntax-rule
: Thisdefine-syntax
macro can be replaced with a simpler, equivalentdefine-syntax-rule
macro.define-syntax-syntax-rules-to-define-syntax-rule
: Thisdefine-syntax
macro can be replaced with a simpler, equivalentdefine-syntax-rule
macro.define-syntax-syntax-rules-to-define-syntax-rule
: Thisdefine-syntax
macro can be replaced with a simpler, equivalentdefine-syntax-rule
macro.Applied 3 fixes to
typed-racket-test/external/tr-random-testing.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.if-begin-to-cond
: Usingcond
instead ofif
here makesbegin
unnecessaryApplied 3 fixes to
typed-racket-lib/typed-racket/types/signatures.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.let-to-define
: Internal definitions are recommended instead oflet
expressions, to reduce nesting.let-to-define
: Internal definitions are recommended instead oflet
expressions, to reduce nesting.Applied 1 fix to
typed-racket-lib/typed-racket/types/struct-table.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.Applied 3 fixes to
typed-racket-lib/typed-racket/types/utils.rkt
define-lambda-to-define
: Thedefine
form supports a shorthand for defining functions.let-to-define
: Internal definitions are recommended instead oflet
expressions, to reduce nesting.let-to-define
: Internal definitions are recommended instead oflet
expressions, to reduce nesting.Applied 4 fixes to
typed-racket-lib/typed-racket/types/prop-ops.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.single-clause-match-to-match-define
: Thismatch
expression can be simplified usingmatch-define
.let-to-define
: Internal definitions are recommended instead oflet
expressions, to reduce nesting.sort-with-keyed-comparator-to-sort-by-key
: Thissort
expression can be replaced with a simpler, equivalent expression.Applied 1 fix to
typed-racket-lib/typed-racket/types/union.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.Applied 2 fixes to
typed-racket-lib/typed-racket/types/generalize.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.let-to-define
: Internal definitions are recommended instead oflet
expressions, to reduce nesting.Applied 1 fix to
typed-racket-test/external/historical-counterexamples.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.Applied 1 fix to
typed-racket-lib/typed-racket/types/substitute.rkt
if-let-to-cond
:cond
with internal definitions is preferred overif
withlet
, to reduce nestingApplied 1 fix to
typed-racket-lib/typed-racket/types/overlap.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.Applied 3 fixes to
typed-racket-lib/typed-racket/types/subtype.rkt
apply-flattening
: Theapply
function accepts single arguments in addition to a trailing list argument.if-else-false-to-and
: Thisif
expression can be refactored to an equivalent expression usingand
.single-clause-match-to-match-define
: Thismatch
expression can be simplified usingmatch-define
.Applied 2 fixes to
typed-racket-lib/typed/private/rewriter.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.syntax-disarm-migration
: Thesyntax-disarm
function is a legacy function that does nothing.Applied 2 fixes to
typed-racket-lib/typed-racket/types/match-expanders.rkt
tidy-require
: Keep imports inrequire
sorted and grouped by phase, with collections before files.define-simple-macro-to-define-syntax-parse-rule
: Thedefine-simple-macro
form has been renamed todefine-syntax-parse-rule
.Applied 3 fixes to
typed-racket-lib/typed-racket/types/resolve.rkt
if-else-false-to-and
: Thisif
expression can be refactored to an equivalent expression usingand
.inverted-when
: This negatedwhen
expression can be replaced by anunless
expression.let-to-define
: Internal definitions are recommended instead oflet
expressions, to reduce nesting.Summary
Fixed 50 issues in 19 files.
tidy-require
single-clause-match-to-match-define
let-to-define
define-syntax-syntax-rules-to-define-syntax-rule
quasiquote-to-list
if-else-false-to-and
define-values-values-to-define
for/fold-result-keyword
apply-append-for-loop-to-for-loop
if-let-to-cond
apply-flattening
syntax-disarm-migration
define-simple-macro-to-define-syntax-parse-rule
inverted-when
if-begin-to-cond
define-lambda-to-define
sort-with-keyed-comparator-to-sort-by-key