-
-
Notifications
You must be signed in to change notification settings - Fork 103
Automated Resyntax fixes #1449
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
Merged
Merged
Automated Resyntax fixes #1449
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
65e7f67
Fix 6 occurrences of `let-to-define`
resyntax-ci[bot] ce970a5
Fix 1 occurrence of `if-else-false-to-and`
resyntax-ci[bot] cf7cb3e
Fix 8 occurrences of `single-clause-match-to-match-define`
resyntax-ci[bot] d891305
Fix 3 occurrences of `zero-comparison-to-positive?`
resyntax-ci[bot] c9c5509
Fix 1 occurrence of `begin0-let-to-define-begin0`
resyntax-ci[bot] 8c451c2
Fix 1 occurrence of `if-let-to-cond`
resyntax-ci[bot] aad59bd
Fix 1 occurrence of `if-x-else-x-to-and`
resyntax-ci[bot] 8cdbe7a
Fix 2 occurrences of `define-simple-macro-to-define-syntax-parse-rule`
resyntax-ci[bot] c0f7441
Fix 1 occurrence of `inverted-unless`
resyntax-ci[bot] e40e358
Fix 3 occurrences of `cond-let-to-cond-define`
resyntax-ci[bot] 78ac288
Fix 2 occurrences of `for/fold-with-conditional-body-to-when-keyword`
resyntax-ci[bot] 33945c1
Fix 2 occurrences of `define-let-to-double-define`
resyntax-ci[bot] 224e239
Fix 1 occurrence of `always-throwing-cond-to-when`
resyntax-ci[bot] ea59282
Fix 1 occurrence of `map-to-for`
resyntax-ci[bot] a26cf51
Fix 2 occurrences of `sort-with-keyed-comparator-to-sort-by-key`
resyntax-ci[bot] ec12a00
Fix 2 occurrences of `format-identity`
resyntax-ci[bot] 8d26a34
Fix 1 occurrence of `for/fold-with-conditional-body-to-when-keyword`
resyntax-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,27 +232,29 @@ | |
(cond | ||
[(pair? args) (values (car args) (cdr args))] | ||
[(syntax? args) | ||
(let ([e (syntax-e args)]) (values (car e) (cdr e)))] | ||
(define e (syntax-e args)) | ||
(values (car e) (cdr e))] | ||
[else | ||
(raise-syntax-error 'shallow-rewrite-top | ||
"#%plain-lambda formals" | ||
#'formals | ||
args)])) | ||
(define check* | ||
(let ([dom+ (for/fold ([acc '()]) ([dom (in-list dom*)]) | ||
(if (pair? dom) | ||
(cons (cdr dom) acc) | ||
acc))]) | ||
(let ([dom+ (for/fold ([acc '()]) | ||
([dom (in-list dom*)] | ||
#:when (pair? dom)) | ||
(cons (cdr dom) acc))]) | ||
(protect-loop rst dom+))) | ||
(define ann-ty | ||
(and (type-annotation fst #:infer #f) | ||
(get-type fst #:infer #t #:default Univ))) | ||
(define fst-ty | ||
(let ([ann-ty (and (type-annotation fst #:infer #f) | ||
(get-type fst #:infer #t #:default Univ))]) | ||
(if (and ann-ty (not (Error? ann-ty))) | ||
ann-ty | ||
(apply Un | ||
(for/list ([dom (in-list dom*)] | ||
#:when (pair? dom)) | ||
(car dom)))))) | ||
(if (and ann-ty (not (Error? ann-ty))) | ||
ann-ty | ||
(apply Un | ||
(for/list ([dom (in-list dom*)] | ||
#:when (pair? dom)) | ||
(car dom))))) | ||
(define-values (ex* fst+) | ||
(if skip-dom? | ||
(values '() #f) | ||
|
@@ -306,29 +308,27 @@ | |
(cond | ||
[(pair? args) (values (car args) (cdr args))] | ||
[(syntax? args) | ||
(let ([e (syntax-e args)]) | ||
(values (car e) (cdr e)))] | ||
(define e (syntax-e args)) | ||
(values (car e) (cdr e))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be a function that does this. |
||
[else | ||
(raise-syntax-error 'shallow-rewrite-top | ||
"#%plain-lambda formals" | ||
formals | ||
args)])) | ||
(define check* | ||
(let ([dom+ (for/fold ([acc '()]) | ||
([dom (in-list dom*)]) | ||
(if (pair? dom) | ||
(cons (cdr dom) acc) | ||
acc))]) | ||
(protect-loop rst dom+))) | ||
(define dom+ | ||
(for/fold ([acc '()]) | ||
([dom (in-list dom*)] | ||
#:when (pair? dom)) | ||
(cons (cdr dom) acc))) | ||
(define check* (protect-loop rst dom+)) | ||
(define fst-ty | ||
(if (type-annotation fst #:infer #f) | ||
(get-type fst #:infer #t #:default Univ) | ||
(apply Un | ||
(for/fold ([acc '()]) | ||
([dom (in-list dom*)]) | ||
(if (pair? dom) | ||
(cons (car dom) acc) | ||
acc))))) | ||
([dom (in-list dom*)] | ||
#:when (pair? dom)) | ||
(cons (car dom) acc))))) | ||
(define-values (ex* fst+) | ||
(if skip-dom? | ||
(values '() #f) | ||
|
@@ -479,7 +479,8 @@ | |
(define-values (fst rst) | ||
(cond | ||
[(pair? v) (values (car v) (cdr v))] | ||
[(syntax? v) (let ([e (syntax-e v)]) (values (car e) (cdr e)))] | ||
[(syntax? v) (define e (syntax-e v)) | ||
(values (car e) (cdr e))] | ||
[else (raise-syntax-error 'formals-fold "lambda formals" stx)])) | ||
(f (loop rst) fst)]))) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could this be a for/list?
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.
cc @jackfirth
Uh oh!
There was an error while loading. Please reload this page.
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.
Such a rewrite would have to add a
reverse
in order to preserve ordering, so Resyntax would rewrite it to this:I'm not sure that's a great idea since it adds two extra linear traversals over the resulting list, making the code slower.
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.
We should have a for/reverse, clearly.
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 all that sure it comes up often enough to be warranted :p I think a lot of the time when the order of a list doesn't matter so using
for/reverse
would be viable, it would also be the case that just using an actually-unordered data structure like a set would be even better.