Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 1, 2025

Adds a keep-sorted macro that marks collections for Resyntax to keep sorted. When elements are out of order, Resyntax suggests reordering them alphabetically by identifier name.

Changes

  • keep-sorted.rkt - Macro that adds a 'keep-sorted syntax property to mark collections
  • default-recommendations/keep-sorted-suggestions.rkt - Refactoring rule that detects unsorted marked lists and suggests sorting
  • default-recommendations/keep-sorted-suggestions-test.rkt - Test coverage
  • default-recommendations.rkt - Added to default recommendations suite

Usage

#lang racket
(require resyntax/keep-sorted)

; Resyntax will suggest reordering to (list apple banana orange)
(keep-sorted (list apple orange banana))

The macro is transparent at runtime—it enables other macros like define-refactoring-suite to expand to keep-sorted and enforce sorted rule lists.

Original prompt

This section details on the original issue you should resolve

<issue_title>Keeping marked lists sorted</issue_title>
<issue_description>It should be possible to tell Resyntax to keep specific collections in sorted order. This could be done with a keep-sorted macro by making a Resyntax rule that looks for a syntax property added by the macro. The first form in the list should be ignored so that this works with any collection, like (list ...), (set ...), or (vector ...). The comparator used could also be customizable by the keep-sorted macro, but it has to be something that operates on the syntax objects contained, not their values.

#lang resyntax/test

test: "unsorted marked list should be resorted"
--------------------
#lang racket
(keep-sorted (list apple orange banana))
--------------------
--------------------
#lang racket
(keep-sorted (list apple banana orange))
--------------------

It should be a macro so that other macros can expand to it. I want this so that define-refactoring-suite can specify that the list of refactoring rules should always be written in sorted order.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add keep-sorted macro for sorted collections Add keep-sorted macro for maintaining sorted lists Dec 1, 2025
Copilot AI requested a review from jackfirth December 1, 2025 17:27
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.

Keeping marked lists sorted

2 participants