On this page:
Resyntax
8.12

Resyntax🔗ℹ

 (require resyntax) package: resyntax

Resyntax is a refactoring tool for Racket. The tool can be guided by refactoring rules, which are macro-like functions defined in terms of syntax-parse that specify how to search for and refactor different coding patterns. Resyntax comes with a standard set of refactoring rules that improve code written in #lang racket/base. For example, consider the following program:

"my-program.rkt"

#lang racket/base
 
(define (swap x y)
  (let ([t (unbox x)])
    (set-box! x (unbox y))
    (set-box! y t)))

This program uses let unnecessarily. The let expression can be replaced with a define form, reducing the indentation of the code. Resyntax is capable of detecting and automatically fixing this issue. Running resyntax fix --file my-program.rkt rewrites the above to the following:

"my-program.rkt"

#lang racket/base
 
(define (swap x y)
  (define t (unbox x))
  (set-box! x (unbox y))
  (set-box! y t))

To see a list of suggestions that Resyntax would apply, use resyntax analyze instead of resyntax fix. Each suggestion includes an explanation of why the change is being recommended.

    1 Installation

    2 The Resyntax Command-Line Interface

      2.1 Running resyntax analyze

      2.2 Running resyntax fix