Skip to content

Commit a7fe898

Browse files
Automated Resyntax fixes
This is an automated change generated by Resyntax. #### Pass 1 Applied 5 fixes to [`typed-racket-lib/typed-racket/static-contracts/constraints.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/static-contracts/constraints.rkt) * Line 184, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 192, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 200, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 207, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 223, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 2 fixes to [`typed-racket-lib/typed-racket/static-contracts/structures.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/static-contracts/structures.rkt) * Line 126, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 130, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 2 fixes to [`typed-racket-lib/typed-racket/static-contracts/instantiate.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt) * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 147, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. #### Pass 2 Applied 1 fix to [`typed-racket-lib/typed-racket/static-contracts/constraints.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/static-contracts/constraints.rkt) * Line 230, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. ## Summary Fixed 10 issues in 3 files. * Fixed 9 occurrences of `single-clause-match-to-match-define` * Fixed 1 occurrence of `tidy-require`
1 parent 42b8e1e commit a7fe898

File tree

3 files changed

+64
-73
lines changed

3 files changed

+64
-73
lines changed

typed-racket-lib/typed-racket/static-contracts/constraints.rkt

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -182,32 +182,26 @@
182182

183183

184184
(define (add-constraint cr max)
185-
(match cr
186-
[(contract-restrict v rec constraints)
187-
(define con (constraint v max))
188-
(if (trivial-constraint? con)
189-
cr
190-
(contract-restrict v rec (set-add constraints con)))]))
185+
(match-define (contract-restrict v rec constraints) cr)
186+
(define con (constraint v max))
187+
(if (trivial-constraint? con) cr (contract-restrict v rec (set-add constraints con))))
191188

192-
(define (add-recursive-values cr dict)
193-
(match cr
194-
[(contract-restrict v rec constraints)
195-
(contract-restrict v (free-id-table-union (list rec dict)) constraints)]))
189+
(define (add-recursive-values cr dict)
190+
(match-define (contract-restrict v rec constraints) cr)
191+
(contract-restrict v (free-id-table-union (list rec dict)) constraints))
196192

197193
(define (merge-restricts* min crs)
198194
(apply merge-restricts min crs))
199195

200196
(define (merge-restricts min . crs)
201-
(match crs
202-
[(list (contract-restrict vs rec constraints) ...)
203-
(contract-restrict (merge-kind-maxes min vs)
204-
(free-id-table-union rec)
205-
(apply set-union (set) constraints))]))
197+
(match-define (list (contract-restrict vs rec constraints) ...) crs)
198+
(contract-restrict (merge-kind-maxes min vs)
199+
(free-id-table-union rec)
200+
(apply set-union (set) constraints)))
206201

207202
(define (merge-kind-maxes min-kind vs)
208-
(match vs
209-
[(list (kind-max variables maxes) ...)
210-
(kind-max (free-id-set-union variables) (apply combine-kinds min-kind maxes))]))
203+
(match-define (list (kind-max variables maxes) ...) vs)
204+
(kind-max (free-id-set-union variables) (apply combine-kinds min-kind maxes)))
211205

212206
(define (close-loop names crs body)
213207
(define eqs (make-equation-set))
@@ -225,35 +219,33 @@
225219
(match km
226220
[(kind-max ids actual)
227221
(define-values (bvals unbound-ids)
228-
(for/fold ([bvals '()] [ubids (make-immutable-free-id-table)])
222+
(for/fold ([bvals '()]
223+
[ubids (make-immutable-free-id-table)])
229224
([(id _) (in-free-id-table ids)])
230225
(if (member id names)
231226
(values (cons (contract-restrict-value (lookup-id id)) bvals) ubids)
232227
(values bvals (free-id-table-set ubids id #t)))))
233228
(merge-kind-maxes 'flat (cons (kind-max unbound-ids actual) bvals))]))
234-
229+
235230
(define (instantiate-constraint con)
236-
(match con
237-
[(constraint km bound)
238-
(constraint (instantiate-kind-max km) bound)]))
239-
240-
(match cr
241-
[(contract-restrict (kind-max ids max) rec constraints)
242-
(define-values (bound-vals unbound-ids)
243-
(for/fold ([bvs '()] [ubids (make-immutable-free-id-table)])
244-
([(id _) (in-free-id-table ids)])
245-
(if (member id names)
246-
(values (cons (lookup-id id) bvs) ubids)
247-
(values bvs (free-id-table-set ubids id #t)))))
248-
(merge-restricts* 'flat (cons
249-
(contract-restrict
250-
(kind-max unbound-ids max)
251-
rec
252-
(for*/set ([c (in-immutable-set constraints)]
253-
[ic (in-value (instantiate-constraint c))]
254-
#:when (not (trivial-constraint? ic)))
255-
ic))
256-
bound-vals))]))
231+
(match-define (constraint km bound) con)
232+
(constraint (instantiate-kind-max km) bound))
233+
(match-define (contract-restrict (kind-max ids max) rec constraints) cr)
234+
(define-values (bound-vals unbound-ids)
235+
(for/fold ([bvs '()]
236+
[ubids (make-immutable-free-id-table)])
237+
([(id _) (in-free-id-table ids)])
238+
(if (member id names)
239+
(values (cons (lookup-id id) bvs) ubids)
240+
(values bvs (free-id-table-set ubids id #t)))))
241+
(merge-restricts* 'flat
242+
(cons (contract-restrict (kind-max unbound-ids max)
243+
rec
244+
(for*/set ([c (in-immutable-set constraints)]
245+
[ic (in-value (instantiate-constraint c))]
246+
#:when (not (trivial-constraint? ic)))
247+
ic))
248+
bound-vals)))
257249

258250
(for ([name (in-list names)]
259251
[cr (in-list crs)])

typed-racket-lib/typed-racket/static-contracts/instantiate.rkt

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22

33
;; Provides functionality to take a static contract and turn it into a regular contract.
44

5-
(require
6-
"../utils/utils.rkt"
7-
racket/match
8-
racket/list
9-
racket/contract
10-
racket/syntax
11-
syntax/private/id-table
12-
(for-template racket/base racket/contract)
13-
"combinators.rkt"
14-
"combinators/name.rkt"
15-
"combinators/case-lambda.rkt"
16-
"combinators/parametric.rkt"
17-
"kinds.rkt"
18-
"optimize.rkt"
19-
"parametric-check.rkt"
20-
"structures.rkt"
21-
"constraints.rkt"
22-
"equations.rkt")
5+
(require (for-template racket/base racket/contract)
6+
racket/contract
7+
racket/list
8+
racket/match
9+
racket/syntax
10+
syntax/private/id-table
11+
"../utils/utils.rkt"
12+
"combinators.rkt"
13+
"combinators/case-lambda.rkt"
14+
"combinators/name.rkt"
15+
"combinators/parametric.rkt"
16+
"constraints.rkt"
17+
"equations.rkt"
18+
"kinds.rkt"
19+
"optimize.rkt"
20+
"parametric-check.rkt"
21+
"structures.rkt")
2322

2423
(provide static-contract-may-contain-free-ids?)
2524

@@ -145,12 +144,14 @@
145144
(variable-ref (hash-ref vars id)))
146145

147146
(for ([(name v) (in-free-id-table recursives)])
148-
(match v
149-
[(kind-max others max)
150-
(add-equation! eqs
151-
(hash-ref vars name)
152-
(λ () (apply combine-kinds max (for/list ([(id _) (in-free-id-table others)])
153-
(lookup id)))))]))
147+
(match-define (kind-max others max) v)
148+
(add-equation! eqs
149+
(hash-ref vars name)
150+
(λ ()
151+
(apply combine-kinds
152+
max
153+
(for/list ([(id _) (in-free-id-table others)])
154+
(lookup id))))))
154155
(define var-values (resolve-equations eqs))
155156
(for/hash ([(name var) (in-hash vars)])
156157
(values name (hash-ref var-values var))))

typed-racket-lib/typed-racket/static-contracts/structures.rkt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,13 @@
124124
#:transparent
125125
#:methods gen:sc
126126
[(define (sc-map v f)
127-
(match v
128-
[(recursive-sc names values body)
129-
(recursive-sc names (map (λ (v) (f v 'covariant)) values) (f body 'covariant))]))
127+
(match-define (recursive-sc names values body) v)
128+
(recursive-sc names (map (λ (v) (f v 'covariant)) values) (f body 'covariant)))
130129
(define (sc-traverse v f)
131-
(match v
132-
[(recursive-sc names values body)
133-
(for-each (λ (v) (f v 'covariant)) values)
134-
(f body 'covariant)
135-
(void)]))
130+
(match-define (recursive-sc names values body) v)
131+
(for-each (λ (v) (f v 'covariant)) values)
132+
(f body 'covariant)
133+
(void))
136134
(define (sc->constraints v f)
137135
(simple-contract-restrict 'impersonator))]
138136
#:methods gen:custom-write [(define write-proc recursive-sc-write-proc)])

0 commit comments

Comments
 (0)