Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Automated Resyntax fixes #1410

wants to merge 1 commit into from

Conversation

resyntax-ci[bot]
Copy link
Contributor

@resyntax-ci resyntax-ci bot commented Nov 8, 2024

This is an automated change generated by Resyntax.

Pass 1

Applied 1 fix to 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

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`
@jackfirth
Copy link
Contributor

Bitten by jackfirth/resyntax#383 yet again.

@jackfirth jackfirth closed this Nov 8, 2024
@@ -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
Copy link
Member

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.

Copy link
Contributor

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))])

Copy link
Member

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

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants