From a1b50111a8e56494a90785dd4b9aca13c0501c31 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 00:41:01 +0000 Subject: [PATCH] Automated Resyntax fixes This is an automated change generated by Resyntax. #### Pass 1 Applied 1 fix to [`collection/private/testing/literal-mutable-red-black-tree.rkt`](../blob/HEAD/collection/private/testing/literal-mutable-red-black-tree.rkt) * Line 35, `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 [`collection/association-list.rkt`](../blob/HEAD/collection/association-list.rkt) * Line 8, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 25, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 26, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. Applied 1 fix to [`type/record/private/definition-macro.rkt`](../blob/HEAD/type/record/private/definition-macro.rkt) * Line 42, `define-simple-macro-to-define-syntax-parse-rule`: The `define-simple-macro` form has been renamed to `define-syntax-parse-rule`. Applied 1 fix to [`collection/private/testing/mutable-red-black-tree-invariants.rkt`](../blob/HEAD/collection/private/testing/mutable-red-black-tree-invariants.rkt) * Line 11, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 2 fixes to [`collection/record.rkt`](../blob/HEAD/collection/record.rkt) * Line 10, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 21, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. Applied 1 fix to [`collection/multiset.rkt`](../blob/HEAD/collection/multiset.rkt) * Line 34, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 3 fixes to [`collection/set.rkt`](../blob/HEAD/collection/set.rkt) * Line 8, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 9, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 10, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. Applied 4 fixes to [`collection/entry.rkt`](../blob/HEAD/collection/entry.rkt) * Line 20, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 21, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 90, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 94, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 2 fixes to [`collection/table.rkt`](../blob/HEAD/collection/table.rkt) * Line 21, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 91, `define-simple-macro-to-define-syntax-parse-rule`: The `define-simple-macro` form has been renamed to `define-syntax-parse-rule`. Applied 2 fixes to [`collection/range-set.rkt`](../blob/HEAD/collection/range-set.rkt) * Line 49, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. * Line 50, `predicate/c-migration`: The `predicate/c` contract is less clear than a `->` contract and no longer improves performance. ## Summary Fixed 20 issues in 10 files. * Fixed 12 occurrences of `predicate/c-migration` * Fixed 3 occurrences of `define-simple-macro-to-define-syntax-parse-rule` * Fixed 3 occurrences of `tidy-require` * Fixed 2 occurrences of `single-clause-match-to-match-define` --- collection/association-list.rkt | 6 +- collection/entry.rkt | 12 +- collection/multiset.rkt | 4 +- .../literal-mutable-red-black-tree.rkt | 4 +- .../mutable-red-black-tree-invariants.rkt | 6 +- collection/range-set.rkt | 4 +- collection/record.rkt | 4 +- collection/set.rkt | 6 +- collection/table.rkt | 42 +++--- type/record/private/definition-macro.rkt | 127 ++++++++---------- 10 files changed, 96 insertions(+), 119 deletions(-) diff --git a/collection/association-list.rkt b/collection/association-list.rkt index 344f36a9..8c6d1395 100644 --- a/collection/association-list.rkt +++ b/collection/association-list.rkt @@ -5,7 +5,7 @@ (provide (contract-out [association-list (->* () #:rest key-value-list/c association-list?)] - [association-list? predicate/c] + [association-list? (-> any/c boolean?)] [association-list-ref (-> association-list? any/c immutable-vector?)] [association-list-size (-> association-list? natural?)] [association-list-keys (-> association-list? multiset?)] @@ -22,8 +22,8 @@ [association-list-contains-value? (-> association-list? any/c boolean?)] [association-list-contains-entry? (-> association-list? entry? boolean?)] [empty-association-list association-list?] - [empty-association-list? predicate/c] - [nonempty-association-list? predicate/c])) + [empty-association-list? (-> any/c boolean?)] + [nonempty-association-list? (-> any/c boolean?)])) (require racket/list racket/math diff --git a/collection/entry.rkt b/collection/entry.rkt index 2762ae3d..8d53dab1 100644 --- a/collection/entry.rkt +++ b/collection/entry.rkt @@ -17,8 +17,8 @@ [mapping-keys (-> (-> any/c any/c) (transducer/c entry? entry?))] [mapping-values (-> (-> any/c any/c) (transducer/c entry? entry?))] [indexing (-> (-> any/c any/c) (transducer/c any/c entry?))] - [filtering-keys (-> predicate/c (transducer/c entry? entry?))] - [filtering-values (-> predicate/c (transducer/c entry? entry?))] + [filtering-keys (-> (-> any/c boolean?) (transducer/c entry? entry?))] + [filtering-values (-> (-> any/c boolean?) (transducer/c entry? entry?))] [append-mapping-keys (-> (-> any/c (sequence/c any/c)) (transducer/c entry? entry?))] [append-mapping-values @@ -87,11 +87,15 @@ (define (mapping-keys key-function) - (mapping (λ (e) (match e [(entry k v) (entry (key-function k) v)])))) + (mapping (λ (e) + (match-define (entry k v) e) + (entry (key-function k) v)))) (define (mapping-values value-function) - (mapping (λ (e) (match e [(entry k v) (entry k (value-function v))])))) + (mapping (λ (e) + (match-define (entry k v) e) + (entry k (value-function v))))) (define (indexing key-function) (bisecting key-function values)) diff --git a/collection/multiset.rkt b/collection/multiset.rkt index 8cdc36f1..bcd37730 100644 --- a/collection/multiset.rkt +++ b/collection/multiset.rkt @@ -32,14 +32,14 @@ (require (for-syntax racket/base) + guard racket/hash racket/math - racket/set racket/sequence + racket/set racket/stream racket/struct rebellion/collection/entry - guard rebellion/private/static-name rebellion/streaming/reducer rebellion/type/record) diff --git a/collection/private/testing/literal-mutable-red-black-tree.rkt b/collection/private/testing/literal-mutable-red-black-tree.rkt index c24fe610..5875eb02 100644 --- a/collection/private/testing/literal-mutable-red-black-tree.rkt +++ b/collection/private/testing/literal-mutable-red-black-tree.rkt @@ -32,8 +32,8 @@ node)))) -(define-simple-macro (mutable-rbtree! - #:key-comparator key-comparator:expr root-node:literal-mutable-rb-node) +(define-syntax-parse-rule (mutable-rbtree! #:key-comparator key-comparator:expr + root-node:literal-mutable-rb-node) (let ([tree (make-mutable-rb-tree key-comparator)] [root root-node.initialization-expr]) (mutable-rb-tree-add-root-child! tree root) diff --git a/collection/private/testing/mutable-red-black-tree-invariants.rkt b/collection/private/testing/mutable-red-black-tree-invariants.rkt index 586bed20..2e079e34 100644 --- a/collection/private/testing/mutable-red-black-tree-invariants.rkt +++ b/collection/private/testing/mutable-red-black-tree-invariants.rkt @@ -8,9 +8,9 @@ (module+ test - (require rackunit - rebellion/collection/private/mutable-red-black-tree-base - guard)) + (require guard + rackunit + rebellion/collection/private/mutable-red-black-tree-base)) ;@---------------------------------------------------------------------------------------------------- diff --git a/collection/range-set.rkt b/collection/range-set.rkt index f83b8840..e8cdb968 100644 --- a/collection/range-set.rkt +++ b/collection/range-set.rkt @@ -46,8 +46,8 @@ (rename-out [range-set-overlaps? range-set-intersects?]) (contract-out - [empty-range-set? predicate/c] - [nonempty-range-set? predicate/c])) + [empty-range-set? (-> any/c boolean?)] + [nonempty-range-set? (-> any/c boolean?)])) (module+ test diff --git a/collection/record.rkt b/collection/record.rkt index 3c657058..abac4483 100644 --- a/collection/record.rkt +++ b/collection/record.rkt @@ -7,7 +7,7 @@ [build-record (-> (-> keyword? any/c) keyset? record?)] [empty-record record?] [record (unconstrained-domain-> record?)] - [record? predicate/c] + [record? (-> any/c boolean?)] [record-contains-key? (-> record? keyword? boolean?)] [record-map (-> record? (-> any/c any/c) record?)] [record-merge2 @@ -18,7 +18,7 @@ [record-remove (-> record? keyword? record?)] [record-size (-> record? natural?)] [record-field (unconstrained-domain-> record-field?)] - [record-field? predicate/c] + [record-field? (-> any/c boolean?)] [record-field-name (-> record-field? keyword?)] [record-field-value (-> record-field? any/c)])) diff --git a/collection/set.rkt b/collection/set.rkt index e1757e4c..156d5b3b 100644 --- a/collection/set.rkt +++ b/collection/set.rkt @@ -5,9 +5,9 @@ (provide (contract-out [empty-set empty-set?] - [empty-set? predicate/c] - [nonempty-set? predicate/c] - [mutable-set? predicate/c] + [empty-set? (-> any/c boolean?)] + [nonempty-set? (-> any/c boolean?)] + [mutable-set? (-> any/c boolean?)] [into-set (reducer/c any/c set?)] [into-mutable-set (reducer/c any/c mutable-set?)])) diff --git a/collection/table.rkt b/collection/table.rkt index 76c8c2c9..2007d6f7 100644 --- a/collection/table.rkt +++ b/collection/table.rkt @@ -19,13 +19,13 @@ [into-table (reducer/c record? table?)])) (require (for-syntax racket/base) + guard racket/math racket/sequence racket/stream rebellion/collection/immutable-vector rebellion/collection/keyset rebellion/collection/record - guard rebellion/private/printer-markup rebellion/private/static-name rebellion/streaming/reducer @@ -88,34 +88,26 @@ (define msg "cannot be used outside a table expression") (raise-syntax-error 'row msg stx)) -(define-simple-macro - (table ((~literal columns) column:keyword ...) - (~and full-row ((~literal row) row-value:expr ...)) ...) - #:do [(define column-keywords - (sort (map syntax-e (syntax->list #'(column ...))) keywordlist #'(column ...))) keywordlist #'(full-row ...))) (define num-rows (length row-stxs))] - #:fail-when (findf (λ (row-stx) - (> (length (syntax->list row-stx)) - (add1 num-columns))) - row-stxs) - (format "too many values in row, table has only ~v columns" num-columns) - #:fail-when (findf (λ (row-stx) - (< (length (syntax->list row-stx)) - (add1 num-columns))) - row-stxs) - (format "not enough values in row, table expects ~v columns" num-columns) + #:fail-when (findf (λ (row-stx) (> (length (syntax->list row-stx)) (add1 num-columns))) + row-stxs) (format "too many values in row, table has only ~v columns" + num-columns) + #:fail-when (findf (λ (row-stx) (< (length (syntax->list row-stx)) (add1 num-columns))) + row-stxs) (format "not enough values in row, table expects ~v columns" + num-columns) #:with size num-rows - #:with ((column-kw column-value ...) ...) - (apply map - list - (syntax->list #'(column ...)) - (map syntax->list (syntax->list #'((row-value ...) ...)))) - #:with ((column-kw-arg ...) ...) - #'((column-kw (immutable-vector column-value ...)) ...) - (constructor:table #:backing-column-vectors (record column-kw-arg ... ...) - #:size 'size)) + #:with ((column-kw column-value ...) ...) (apply map + list + (syntax->list #'(column ...)) + (map syntax->list + (syntax->list #'((row-value ...) ...)))) + #:with ((column-kw-arg ...) ...) #'((column-kw (immutable-vector column-value ...)) ...) + (constructor:table #:backing-column-vectors (record column-kw-arg ... ...) #:size 'size)) (define (table-columns-ref tab column) (record-ref (table-backing-column-vectors tab) column)) diff --git a/type/record/private/definition-macro.rkt b/type/record/private/definition-macro.rkt index ace525d0..07cfc6e1 100644 --- a/type/record/private/definition-macro.rkt +++ b/type/record/private/definition-macro.rkt @@ -39,87 +39,68 @@ #:with (position ...) (for/list ([_ (in-syntax #'(id ...))] [n (in-naturals)]) #`'#,n)))) -(define-simple-macro - (define-record-type id:id fields:record-fields - (~alt - (~optional (~and #:omit-root-binding omit-root-binding-kw)) +(define-syntax-parse-rule (define-record-type + id:id + fields:record-fields + (~alt + (~optional (~and #:omit-root-binding omit-root-binding-kw)) + (~optional (~seq #:descriptor-name descriptor:id) + #:defaults ([descriptor (default-descriptor-identifier #'id)]) + #:name "#:descriptor-name option") + (~optional (~seq #:predicate-name predicate:id) + #:defaults ([predicate (default-predicate-identifier #'id)]) + #:name "#:predicate-name option") + (~optional (~seq #:constructor-name constructor:id) + #:defaults ([constructor + (default-constructor-identifier #'id)]) + #:name "#:constructor-name option") + (~optional (~seq #:accessor-name accessor:id) + #:defaults ([accessor (default-accessor-identifier #'id)]) + #:name "#:accessor-name option") + (~optional (~seq #:pattern-name pattern:id) + #:defaults ((pattern (default-pattern-identifier #'id))) + #:name "#:pattern-name option") + (~optional (~seq #:inspector inspector:expr) + #:name "#:inspector option" + #:defaults ([inspector #'(current-inspector)])) + (~optional (~seq #:property-maker prop-maker:expr) + #:defaults ([prop-maker #'default-record-properties]) + #:name "#:property-maker option")) ...) - (~optional - (~seq #:descriptor-name descriptor:id) - #:defaults ([descriptor (default-descriptor-identifier #'id)]) - #:name "#:descriptor-name option") - - (~optional - (~seq #:predicate-name predicate:id) - #:defaults ([predicate (default-predicate-identifier #'id)]) - #:name "#:predicate-name option") - - (~optional - (~seq #:constructor-name constructor:id) - #:defaults ([constructor (default-constructor-identifier #'id)]) - #:name "#:constructor-name option") - - (~optional - (~seq #:accessor-name accessor:id) - #:defaults ([accessor (default-accessor-identifier #'id)]) - #:name "#:accessor-name option") - - (~optional - (~seq #:pattern-name pattern:id) - #:defaults ([pattern (default-pattern-identifier #'id)]) - #:name "#:pattern-name option") + #:with (field-accessor ...) (for/list ([field-id-stx (in-syntax #'(fields.id ...))]) + (default-field-accessor-identifier #'id field-id-stx)) - (~optional - (~seq #:inspector inspector:expr) - #:name "#:inspector option" - #:defaults ([inspector #'(current-inspector)])) - - (~optional - (~seq #:property-maker prop-maker:expr) - #:defaults ([prop-maker #'default-record-properties]) - #:name "#:property-maker option")) - ...) - - #:with (field-accessor ...) - (for/list ([field-id-stx (in-syntax #'(fields.id ...))]) - (default-field-accessor-identifier #'id field-id-stx)) + #:with root-binding (if (attribute omit-root-binding-kw) + #'(begin) + #'(define-syntax id + (record-binding #:type (record-type 'id + fields.keys + #:predicate-name 'predicate + #:constructor-name 'constructor + #:accessor-name 'accessor) + #:descriptor #'descriptor + #:predicate #'predicate + #:constructor #'constructor + #:accessor #'accessor + #:fields (list #'fields.id ...) + #:field-accessors (list #'field-accessor ...) + #:pattern #'pattern + #:macro + (make-variable-like-transformer #'constructor)))) - #:with root-binding - (if (attribute omit-root-binding-kw) - #'(begin) - #'(define-syntax id - (record-binding - #:type - (record-type - 'id fields.keys - #:predicate-name 'predicate - #:constructor-name 'constructor - #:accessor-name 'accessor) - #:descriptor #'descriptor - #:predicate #'predicate - #:constructor #'constructor - #:accessor #'accessor - #:fields (list #'fields.id ...) - #:field-accessors (list #'field-accessor ...) - #:pattern #'pattern - #:macro (make-variable-like-transformer #'constructor)))) - (begin (define descriptor - (make-record-implementation - (record-type - 'id fields.keys - #:predicate-name 'predicate - #:constructor-name 'constructor - #:accessor-name 'accessor) - #:inspector inspector - #:property-maker prop-maker)) + (make-record-implementation (record-type 'id + fields.keys + #:predicate-name 'predicate + #:constructor-name 'constructor + #:accessor-name 'accessor) + #:inspector inspector + #:property-maker prop-maker)) (define predicate (record-descriptor-predicate descriptor)) (define constructor (record-descriptor-constructor descriptor)) (define accessor (record-descriptor-accessor descriptor)) - (define field-accessor - (make-record-field-accessor descriptor fields.position)) - ... + (define field-accessor (make-record-field-accessor descriptor fields.position)) ... (define-match-expander pattern (syntax-parser #:track-literals