resyntax icon indicating copy to clipboard operation
resyntax copied to clipboard

New rule: `flatten-apply-append-syntax-template`

Open jackfirth opened this issue 3 months ago • 0 comments

Rule summary

The code (apply append (map syntax->list (syntax->list #'((id ...) ...)))) is more directly expressed as (syntax->list #'(id ... ...)).

Test case

#lang resyntax/test

test: "original code should be refactorable to new code"
--------------------
#lang racket
(define (f stx)
  (with-syntax ([((a ...) ...) stx])
    (apply append
           (map syntax->list (syntax->list #'((a ...) ...))))))
====================
#lang racket
(define (f stx)
  (with-syntax ([((a ...) ...) stx])
    (syntax->list #'(a ... ...))))
--------------------

Additional context

Saw this here in racket/drracket#783.

jackfirth avatar Nov 18 '25 18:11 jackfirth