Skip to content

Commit 0f8219b

Browse files
Automated Resyntax fixes
This is an automated change generated by Resyntax. #### Pass 1 Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/possible-domains.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/possible-domains.rkt) * Line 58, `and-match-to-match`: This `and` expression can be turned into a clause of the inner `match` expression, reducing nesting. Applied 2 fixes to [`typed-racket-lib/typed-racket/typecheck/integer-refinements.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/integer-refinements.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 74, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. Applied 3 fixes to [`typed-racket-lib/typed-racket/typecheck/toplevel-trampoline.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/toplevel-trampoline.rkt) * Line 11, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 34, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 64, `if-begin-to-cond`: Using `cond` instead of `if` here makes `begin` unnecessary Applied 1 fix to [`typed-racket-lib/typed-racket/private/type-annotation.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/type-annotation.rkt) * Line 92, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 2 fixes to [`typed-racket-lib/typed-racket/private/user-defined-type-constr.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/user-defined-type-constr.rkt) * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 32, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/check-unit-unit.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/check-unit-unit.rkt) * Line 178, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. Applied 15 fixes to [`typed-racket-lib/typed-racket/private/type-contract.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/type-contract.rkt) * Line 242, `if-begin-to-cond`: Using `cond` instead of `if` here makes `begin` unnecessary * Line 389, `unused-definition`: This definition is not used. * Line 557, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 838, `always-throwing-cond-to-when`: Using `when` and `unless` is simpler than a conditional with an always-throwing branch. * Line 1139, `unused-definition`: This definition is not used. * Line 1167, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 1270, `zero-comparison-lambda-to-positive?`: This lambda function is equivalent to the built-in `positive?` predicate. * Line 1290, `map-to-for`: This `map` operation can be replaced with a `for/list` loop. * Line 1295, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 1324, `unused-definition`: This definition is not used. * Line 1549, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 1550, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 1551, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 1552, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 1553, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. Applied 8 fixes to [`typed-racket-lib/typed-racket/private/shallow-rewrite.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/shallow-rewrite.rkt) * Line 225, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting * Line 275, `define-let-to-double-define`: This `let` expression can be pulled up into a `define` expression. * Line 287, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting * Line 418, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 428, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 452, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting * Line 632, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 717, `unused-definition`: This definition is not used. Applied 2 fixes to [`typed-racket-lib/typed-racket/private/with-types.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/with-types.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 53, `inverted-unless`: This negated `unless` expression can be replaced by a `when` expression. Applied 2 fixes to [`typed-racket-lib/typed-racket/typecheck/check-below.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/check-below.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 86, `unused-definition`: This definition is not used. Applied 3 fixes to [`typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt) * Line 96, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 146, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 197, `format-identity`: This use of `format` does nothing. Applied 1 fix to [`typed-racket-lib/typed-racket/private/syntax-properties.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/syntax-properties.rkt) * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/private/parse-classes.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/parse-classes.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 3 fixes to [`typed-racket-lib/typed-racket/private/parse-type.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/private/parse-type.rkt) * Line 186, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 1509, `for/fold-with-conditional-body-to-unless-keyword`: This `for/fold` loop can be simplified by using the `#:unless` keyword. * Line 1658, `inline-unnecessary-define`: This variable is returned immediately and can be inlined. ## Summary Fixed 45 issues in 14 files. * Fixed 8 occurrences of `tidy-require` * Fixed 7 occurrences of `let-to-define` * Fixed 7 occurrences of `define-lambda-to-define` * Fixed 5 occurrences of `unused-definition` * Fixed 4 occurrences of `single-clause-match-to-match-define` * Fixed 3 occurrences of `if-let-to-cond` * Fixed 2 occurrences of `if-begin-to-cond` * Fixed 1 occurrence of `and-match-to-match` * Fixed 1 occurrence of `format-identity` * Fixed 1 occurrence of `for/fold-with-conditional-body-to-unless-keyword` * Fixed 1 occurrence of `inline-unnecessary-define` * Fixed 1 occurrence of `always-throwing-cond-to-when` * Fixed 1 occurrence of `zero-comparison-lambda-to-positive?` * Fixed 1 occurrence of `map-to-for` * Fixed 1 occurrence of `define-let-to-double-define` * Fixed 1 occurrence of `inverted-unless`
1 parent 8359319 commit 0f8219b

14 files changed

+411
-393
lines changed

typed-racket-lib/typed-racket/private/parse-classes.rkt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#lang racket/base
22

3-
(require syntax/parse/pre
4-
"../utils/literal-syntax-class.rkt"
5-
(for-label "../base-env/base-types-extra.rkt"))
3+
(require (for-label "../base-env/base-types-extra.rkt")
4+
syntax/parse/pre
5+
"../utils/literal-syntax-class.rkt")
66
(provide star ddd ddd/bound omit-parens)
77

88
(define-literal-syntax-class #:for-label ->)

typed-racket-lib/typed-racket/private/parse-type.rkt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@
183183
;; (Syntax -> Type) -> Syntax Any -> Syntax
184184
;; See `parse-type/id`. This is a curried generalization.
185185
(define ((parse/id p) loc datum)
186-
(let* ([stx* (datum->syntax loc datum loc loc)])
187-
(p stx*)))
186+
(define stx* (datum->syntax loc datum loc loc))
187+
(p stx*))
188188

189189
(define (parse-literal-alls stx)
190190
(syntax-parse stx
@@ -1507,10 +1507,9 @@
15071507
;; Merge all the non-duplicate entries from the parent types
15081508
(define (merge-clause parent-clause clause)
15091509
(for/fold ([clause clause])
1510-
([(k v) (in-dict parent-clause)])
1511-
(if (dict-has-key? clause k)
1512-
clause
1513-
(dict-set clause k v))))
1510+
([(k v) (in-dict parent-clause)]
1511+
#:unless (dict-has-key? clause k))
1512+
(dict-set clause k v)))
15141513

15151514
(define (match-parent-type parent-type)
15161515
(define resolved (resolve parent-type))
@@ -1655,12 +1654,12 @@
16551654
;; of init arguments.
16561655
(define parent-inits (get-parent-inits parent/init-type))
16571656

1658-
(define class-type
1659-
(make-Class row-var
1660-
(append given-inits parent-inits)
1661-
fields methods augments given-init-rest))
1662-
1663-
class-type]
1657+
(make-Class row-var
1658+
(append given-inits parent-inits)
1659+
fields
1660+
methods
1661+
augments
1662+
given-init-rest)]
16641663
[else
16651664
;; Conservatively assume that if there *are* #:implements
16661665
;; clauses, then the current type alias will be recursive

typed-racket-lib/typed-racket/private/shallow-rewrite.rkt

Lines changed: 110 additions & 96 deletions
Large diffs are not rendered by default.

typed-racket-lib/typed-racket/private/syntax-properties.rkt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#lang racket/base
2-
(require
3-
syntax/parse/pre
4-
(for-syntax racket/base syntax/parse/pre racket/syntax))
2+
(require (for-syntax racket/base
3+
racket/syntax
4+
syntax/parse/pre)
5+
syntax/parse/pre)
56

67
(define-syntax define-matcher
78
(syntax-parser

typed-racket-lib/typed-racket/private/type-annotation.rkt

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -89,46 +89,49 @@
8989
(listof tc-result?))
9090
(match stxs
9191
[(list stx ...)
92-
(let ([anns (for/list ([s (in-list stxs)])
93-
(cond
94-
;; if the lhs identifier is the rest parameter, its type is
95-
;; (Listof ty), where ty is the annotated type
96-
[(rst-arg-property s)
97-
(make-Listof (type-annotation s #:infer #t))]
98-
[else (type-annotation s #:infer #t)]))])
99-
(if (for/and ([a (in-list anns)]) a)
100-
(match (tc-expr/check expr (ret anns))
101-
[(tc-results: tcrs _) tcrs])
102-
(match (tc-expr expr)
103-
[(tc-any-results: _)
104-
(tc-error/expr
105-
#:return (map (λ _ (-tc-result -Bottom)) stxs)
106-
"Expression should produce ~a values, but produces an unknown number of values"
107-
(length stxs))]
108-
[(tc-result1: (== -Bottom))
109-
(for/list ([_ (in-range (length stxs))])
110-
(-tc-result -Bottom))]
111-
[(tc-results: tcrs _)
112-
(cond
113-
[(not (= (length stxs) (length tcrs)))
114-
(tc-error/expr #:return (map (λ _ (-tc-result -Bottom)) stxs)
115-
"Expression should produce ~a values, but produces ~a values of types ~a"
116-
(length stxs)
117-
(length tcrs)
118-
(stringify (map tc-result-t tcrs)))]
119-
[else
120-
(for/list ([stx (in-list stxs)]
121-
[tcr (in-list tcrs)]
122-
[a (in-list anns)])
123-
(match tcr
124-
[(tc-result: ty ps o)
125-
(cond [a (check-type stx ty a)
126-
(-tc-result a ps o)]
127-
;; mutated variables get generalized, so that we don't
128-
;; infer too small a type
129-
[(is-var-mutated? stx)
130-
(-tc-result (generalize ty) ps o)]
131-
[else (-tc-result ty ps o)])]))])])))]))
92+
(define anns
93+
(for/list ([s (in-list stxs)])
94+
(cond
95+
;; if the lhs identifier is the rest parameter, its type is
96+
;; (Listof ty), where ty is the annotated type
97+
[(rst-arg-property s) (make-Listof (type-annotation s #:infer #t))]
98+
[else (type-annotation s #:infer #t)])))
99+
(if (for/and ([a (in-list anns)])
100+
a)
101+
(match (tc-expr/check expr (ret anns))
102+
[(tc-results: tcrs _) tcrs])
103+
(match (tc-expr expr)
104+
[(tc-any-results: _)
105+
(tc-error/expr
106+
#:return (map (λ _ (-tc-result -Bottom)) stxs)
107+
"Expression should produce ~a values, but produces an unknown number of values"
108+
(length stxs))]
109+
[(tc-result1: (== -Bottom))
110+
(for/list ([_ (in-range (length stxs))])
111+
(-tc-result -Bottom))]
112+
[(tc-results: tcrs _)
113+
(cond
114+
[(not (= (length stxs) (length tcrs)))
115+
(tc-error/expr
116+
#:return (map (λ _ (-tc-result -Bottom)) stxs)
117+
"Expression should produce ~a values, but produces ~a values of types ~a"
118+
(length stxs)
119+
(length tcrs)
120+
(stringify (map tc-result-t tcrs)))]
121+
[else
122+
(for/list ([stx (in-list stxs)]
123+
[tcr (in-list tcrs)]
124+
[a (in-list anns)])
125+
(match tcr
126+
[(tc-result: ty ps o)
127+
(cond
128+
[a
129+
(check-type stx ty a)
130+
(-tc-result a ps o)]
131+
;; mutated variables get generalized, so that we don't
132+
;; infer too small a type
133+
[(is-var-mutated? stx) (-tc-result (generalize ty) ps o)]
134+
[else (-tc-result ty ps o)])]))])]))]))
132135

133136
;; check that e-type is compatible with ty in context of stx
134137
;; otherwise, error

typed-racket-lib/typed-racket/private/type-contract.rkt

Lines changed: 59 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,11 @@
239239
(define (change-contract-fixups forms [ctc-cache (make-hash)])
240240
(with-new-name-tables
241241
(for/list ((e (in-list forms)))
242-
(if (not (has-contract-def-property? e))
243-
e
244-
(begin (set-box! include-extra-requires? #t)
245-
(generate-contract-def e ctc-cache))))))
242+
(cond
243+
[(not (has-contract-def-property? e)) e]
244+
[else
245+
(set-box! include-extra-requires? #t)
246+
(generate-contract-def e ctc-cache)]))))
246247

247248
;; TODO: These are probably all in a specific place, which could avoid
248249
;; the big traversal
@@ -386,8 +387,8 @@
386387
(loop t (flip-side typed-side) recursive-values))
387388
(define (t->sc/both t #:recursive-values (recursive-values recursive-values))
388389
(loop t 'both recursive-values))
389-
(define (t->sc/fun t #:maybe-existential [opt-exi #f]) (t->sc/function t fail typed-side recursive-values loop #f #:maybe-existential opt-exi))
390-
(define (t->sc/meth t) (t->sc/method t fail typed-side recursive-values loop))
390+
(define (t->sc/meth t)
391+
(t->sc/method t fail typed-side recursive-values loop))
391392

392393
(define (struct->recursive-sc name-base key flds sc-ctor)
393394
(define key* (generate-temporary name-base))
@@ -554,13 +555,11 @@
554555
;; Avoid putting (-> any T) contracts on struct predicates (where Boolean <: T)
555556
;; Optimization: if the value is typed, we can assume it's not wrapped
556557
;; in a type-unsafe chaperone/impersonator and use the unsafe contract
557-
(let* ([unsafe-spp/sc (flat/sc #'struct-predicate-procedure?)]
558-
[safe-spp/sc (flat/sc #'struct-predicate-procedure?/c)]
559-
[optimized/sc (if (from-typed? typed-side)
560-
unsafe-spp/sc
561-
safe-spp/sc)]
562-
[spt-pred-procedure?/sc (flat/sc #'struct-type-property-predicate-procedure?)])
563-
(or/sc optimized/sc spt-pred-procedure?/sc (t->sc/fun t)))]
558+
(define unsafe-spp/sc (flat/sc #'struct-predicate-procedure?))
559+
(define safe-spp/sc (flat/sc #'struct-predicate-procedure?/c))
560+
(define optimized/sc (if (from-typed? typed-side) unsafe-spp/sc safe-spp/sc))
561+
(define spt-pred-procedure?/sc (flat/sc #'struct-type-property-predicate-procedure?))
562+
(or/sc optimized/sc spt-pred-procedure?/sc (t->sc/fun t))]
564563
[(? Fun? t) (t->sc/fun t)]
565564
[(? DepFun? t) (t->sc/fun t)]
566565
[(Set: t) (set/sc (t->sc t))]
@@ -835,10 +834,10 @@
835834
[else (is-flat-type/sc (obj->sc o) sc)])]
836835
[(NotTypeProp: o t)
837836
(define sc (t->sc t bound-all-vars))
838-
(cond
839-
[(not (equal? flat-sym (get-max-contract-kind sc)))
840-
(raise-user-error 'type->static-contract/shallow "proposition contract generation not supported for non-flat types")]
841-
[else (not-flat-type/sc (obj->sc o) sc)])]
837+
(unless (equal? flat-sym (get-max-contract-kind sc))
838+
(raise-user-error 'type->static-contract/shallow
839+
"proposition contract generation not supported for non-flat types"))
840+
(not-flat-type/sc (obj->sc o) sc)]
842841
[(LeqProp: (app obj->sc lhs) (app obj->sc rhs))
843842
(leq/sc lhs rhs)]
844843
[(AndProp: ps)
@@ -1136,39 +1135,34 @@
11361135
(define (t->sc/function f fail typed-side recursive-values loop method? #:maybe-existential [opt-exi #f])
11371136
(define (t->sc t #:recursive-values (recursive-values recursive-values))
11381137
(loop t typed-side recursive-values))
1139-
(define (t->sc/neg t #:recursive-values (recursive-values recursive-values))
1140-
(loop t (flip-side typed-side) recursive-values))
1141-
11421138
(define (arr-params->exist/sc exi dom rst kw rng prop+type)
11431139
(define (occur? t)
1144-
(if (or (not t) (empty? t)) #f
1140+
(if (or (not t) (empty? t))
1141+
#f
11451142
(set-member? (free-vars-names (free-vars* t)) exi)))
1146-
1143+
11471144
(match* (rng prop+type)
11481145
[((Fun: (list (Arrow: (list-rest (F: n1) a ... _) rst_i kw_i _))) (F: n1))
1149-
#:when (and (not (ormap occur? (list rst kw rst_i kw_i)))
1150-
(eq? n1 exi))
1146+
#:when (and (not (ormap occur? (list rst kw rst_i kw_i))) (eq? n1 exi))
11511147
(void)]
1152-
[(_ _) (fail #:reason
1153-
"contract generation only supports Some Type in this form: (Some (X) (-> ty1 ... (-> X ty ... ty2) : X)) or (-> ty1 ... (Some (X) (-> X ty ... ty2) : X))")])
1154-
1148+
[(_ _)
1149+
(fail
1150+
#:reason
1151+
"contract generation only supports Some Type in this form: (Some (X) (-> ty1 ... (-> X ty ... ty2) : X)) or (-> ty1 ... (Some (X) (-> X ty ... ty2) : X))")])
1152+
11551153
(define/with-syntax name exi)
11561154
(define lhs (t->sc/neg dom))
11571155
(define eq-name (flat/sc #'(eq/c name)))
1158-
(define rhs (t->sc rng
1159-
#:recursive-values (hash-set recursive-values exi
1160-
(same eq-name))))
1156+
(define rhs (t->sc rng #:recursive-values (hash-set recursive-values exi (same eq-name))))
11611157
(exist/sc (list #'name) lhs rhs))
11621158

11631159

11641160
;; handle-arrow-range : Arr (-> Static-Contact) -> Static-Contract
11651161
;; Match the range of an arr and determine if a contract can be generated
11661162
;; and call the given thunk or raise an error
11671163
(define (handle-arrow-range arrow proceed)
1168-
(match arrow
1169-
[(or (Arrow: _ _ _ rng)
1170-
(DepFun: _ _ rng))
1171-
(handle-range rng proceed)]))
1164+
(match-define (or (Arrow: _ _ _ rng) (DepFun: _ _ rng)) arrow)
1165+
(handle-range rng proceed))
11721166
(define (handle-range rng proceed)
11731167
(match rng
11741168
[(Values: (list (Result: _
@@ -1267,8 +1261,7 @@
12671261
(when (and (not (empty? kws)))
12681262
(fail #:reason (~a "cannot generate contract for case function type"
12691263
" with optional keyword arguments")))
1270-
(when (ormap (lambda (n-exi)
1271-
(> n-exi 0))
1264+
(when (ormap positive?
12721265
n-exis)
12731266
(fail #:reason (~a "cannot generate contract for case function type with existentials")))
12741267

@@ -1287,51 +1280,35 @@
12871280
(handle-arrow-range (first arrows)
12881281
(lambda ()
12891282
(convert-single-arrow (first arrows))))
1290-
(case->/sc (map (lambda (arr)
1291-
(handle-arrow-range arr (lambda ()
1292-
(convert-one-arrow-in-many arr))))
1293-
arrows)))])]
1283+
(case->/sc (for/list ([arr (in-list arrows)])
1284+
(handle-arrow-range arr (lambda () (convert-one-arrow-in-many arr))))))])]
12941285
[(DepFun/ids: ids dom pre rng)
12951286
(define (continue)
1296-
(match rng
1297-
[(Values: (list (Result: rngs _ _) ...))
1298-
(define (dom-id? id) (member id ids free-identifier=?))
1299-
(define-values (dom* dom-deps)
1300-
(for/lists (_1 _2) ([d (in-list dom)])
1301-
(values (t->sc/neg d)
1302-
(filter dom-id? (free-ids d)))))
1303-
(define pre* (if (TrueProp? pre) #f (t->sc/neg pre)))
1304-
(define pre-deps (filter dom-id? (free-ids pre)))
1305-
(define rng* (map t->sc rngs))
1306-
(define rng-deps (filter dom-id?
1307-
(remove-duplicates
1308-
(apply append (map free-ids rngs))
1309-
free-identifier=?)))
1310-
(->i/sc (from-typed? typed-side)
1311-
ids
1312-
dom*
1313-
dom-deps
1314-
pre*
1315-
pre-deps
1316-
rng*
1317-
rng-deps)]))
1287+
(match-define (Values: (list (Result: rngs _ _) ...)) rng)
1288+
(define (dom-id? id)
1289+
(member id ids free-identifier=?))
1290+
(define-values (dom* dom-deps)
1291+
(for/lists (_1 _2) ([d (in-list dom)]) (values (t->sc/neg d) (filter dom-id? (free-ids d)))))
1292+
(define pre*
1293+
(if (TrueProp? pre)
1294+
#f
1295+
(t->sc/neg pre)))
1296+
(define pre-deps (filter dom-id? (free-ids pre)))
1297+
(define rng* (map t->sc rngs))
1298+
(define rng-deps
1299+
(filter dom-id? (remove-duplicates (apply append (map free-ids rngs)) free-identifier=?)))
1300+
(->i/sc (from-typed? typed-side) ids dom* dom-deps pre* pre-deps rng* rng-deps))
13181301
(handle-range rng continue)]))
13191302

13201303
;; Generate a contract for a object/class method clause
13211304
;; Precondition: type is a valid method type
13221305
(define (t->sc/method type fail typed-side recursive-values loop)
13231306
;; helper for mutually recursive calls in Poly cases
1324-
(define (rec body #:recursive-values rv)
1325-
(t->sc/method body fail typed-side rv loop))
13261307
(match type
1327-
[(? Poly?)
1328-
(t->sc/poly type fail typed-side recursive-values rec)]
1329-
[(? PolyDots?)
1330-
(t->sc/polydots type fail typed-side recursive-values rec)]
1331-
[(? PolyRow?)
1332-
(t->sc/polyrow type fail typed-side recursive-values rec)]
1333-
[(? Fun?)
1334-
(t->sc/function type fail typed-side recursive-values loop #t)]
1308+
[(? Poly?) (t->sc/poly type fail typed-side recursive-values rec)]
1309+
[(? PolyDots?) (t->sc/polydots type fail typed-side recursive-values rec)]
1310+
[(? PolyRow?) (t->sc/polyrow type fail typed-side recursive-values rec)]
1311+
[(? Fun?) (t->sc/function type fail typed-side recursive-values loop #t)]
13351312
[_ (fail #:reason "invalid method type")]))
13361313

13371314
(define (is-a-function-type? initial)
@@ -1546,11 +1523,16 @@
15461523
(require racket/extflonum)
15471524
(provide nonnegative? nonpositive?
15481525
extflonum? extflzero? extflnonnegative? extflnonpositive?)
1549-
(define nonnegative? (lambda (x) (>= x 0)))
1550-
(define nonpositive? (lambda (x) (<= x 0)))
1551-
(define extflzero? (lambda (x) (extfl= x 0.0t0)))
1552-
(define extflnonnegative? (lambda (x) (extfl>= x 0.0t0)))
1553-
(define extflnonpositive? (lambda (x) (extfl<= x 0.0t0))))
1526+
(define (nonnegative? x)
1527+
(>= x 0))
1528+
(define (nonpositive? x)
1529+
(<= x 0))
1530+
(define (extflzero? x)
1531+
(extfl= x 0.0t0))
1532+
(define (extflnonnegative? x)
1533+
(extfl>= x 0.0t0))
1534+
(define (extflnonpositive? x)
1535+
(extfl<= x 0.0t0)))
15541536

15551537
(module numeric-contracts racket/base
15561538
(require

typed-racket-lib/typed-racket/private/user-defined-type-constr.rkt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#lang racket/base
2-
(require "../rep/type-constr.rkt"
2+
(require racket/lazy-require
33
racket/match
4-
racket/lazy-require)
4+
"../rep/type-constr.rkt")
55

66
(lazy-require ["../types/substitute.rkt"
77
(subst-all make-simple-substitution)])
@@ -30,7 +30,8 @@
3030
[_ #f]))
3131

3232
(define (recursive-type-constr? constr)
33-
(match constr
34-
[(struct* TypeConstructor
35-
([real-trep-constr (struct* user-defined-type-op ([recursive? recursive?]))]))
36-
recursive?]))
33+
(match-define (struct* TypeConstructor
34+
([real-trep-constr
35+
(struct* user-defined-type-op ([recursive? recursive?]))]))
36+
constr)
37+
recursive?)

0 commit comments

Comments
 (0)