Skip to content

Commit a15559a

Browse files
committed
Authentic structs for static contracts.
1 parent 6a042da commit a15559a

20 files changed

+47
-9
lines changed

typed-racket-lib/typed-racket/static-contracts/combinators/any.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
(struct any-combinator combinator ()
2929
#:transparent
30+
#:authentic
3031
#:methods gen:sc
3132
[(define (sc-map v f) v)
3233
(define (sc-traverse v f) (void))

typed-racket-lib/typed-racket/static-contracts/combinators/case-lambda.rkt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
(struct case-combinator combinator ()
2626
#:transparent
27+
#:authentic
2728
#:property prop:combinator-name "case->/sc"
2829
#:methods gen:sc
2930
[(define (sc-map v f)
@@ -38,6 +39,7 @@
3839
(struct arr-combinator combinator ()
3940
#:transparent
4041
#:property prop:combinator-name "arr/sc"
42+
#:authentic
4143
#:methods gen:sc
4244
[(define (sc-map v f)
4345
(arr-combinator (arr-seq-sc-map f (combinator-args v))))
@@ -83,6 +85,7 @@
8385

8486

8587
(struct arr-seq (args rest range)
88+
#:authentic
8689
#:transparent
8790
#:property prop:sequence
8891
(match-lambda

typed-racket-lib/typed-racket/static-contracts/combinators/control.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
[prompt-tag/sc ((listof static-contract?) (or/c (listof static-contract?) #f) . -> . static-contract?)])
1616

1717
(struct prompt-tag-combinator combinator ()
18+
#:authentic
1819
#:transparent
1920
#:property prop:combinator-name "prompt-tag/sc"
2021
#:methods gen:sc
@@ -36,6 +37,7 @@
3637
(merge-restricts* 'chaperone (map f (pt-seq->list (combinator-args v)))))])
3738

3839
(struct pt-seq (vals call-cc)
40+
#:authentic
3941
#:transparent
4042
#:property prop:sequence
4143
(lambda (s)

typed-racket-lib/typed-racket/static-contracts/combinators/dep-function.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
pre-deps
2222
rng
2323
rng-deps)
24+
#:authentic
2425
#:transparent
2526
#:property prop:combinator-name "dep->/sc"
2627
#:methods gen:sc

typed-racket-lib/typed-racket/static-contracts/combinators/exist.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
(struct exist-combinator combinator ()
19+
#:authentic
1920
#:transparent
2021
#:methods gen:sc
2122
[(define (sc-map v f)

typed-racket-lib/typed-racket/static-contracts/combinators/function.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
static-contract?)])
2424

2525
(struct function-combinator combinator (indices mand-kws opt-kws typed-side?)
26+
#:authentic
2627
#:property prop:combinator-name "->/sc"
2728
#:methods gen:equal+hash [(define (equal-proc a b recur) (function-sc-equal? a b recur))
2829
(define (hash-proc v recur) (function-sc-hash v recur))

typed-racket-lib/typed-racket/static-contracts/combinators/name.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
(list typed-sc untyped-sc both-sc)))
9393

9494
(struct name-combinator combinator (gen-name)
95+
#:authentic
9596
#:transparent
9697
#:property prop:combinator-name "name/sc"
9798
#:methods gen:sc

typed-racket-lib/typed-racket/static-contracts/combinators/none.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
(display "#<none/sc>" port)))
2424

2525
(struct none-combinator combinator ()
26+
#:authentic
2627
#:transparent
2728
#:methods gen:sc
2829
[(define (sc-map v f) v)

typed-racket-lib/typed-racket/static-contracts/combinators/object.rkt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
typed-racket/utils/opaque-object)
1414
(for-syntax racket/base syntax/parse))
1515

16-
(struct member-spec (modifier id sc) #:transparent)
16+
(struct member-spec (modifier id sc) #:authentic #:transparent)
1717

1818
(define field-modifiers '(field init init-field inherit-field))
1919
(define method-modifiers '(method inherit super inner override augment augride))
2020

2121
(struct object-combinator combinator (opaque?)
22+
#:authentic
2223
#:transparent
2324
#:property prop:combinator-name "object/sc"
2425
#:methods gen:sc
@@ -34,6 +35,7 @@
3435
(merge-restricts* 'impersonator (map f (member-seq->list (combinator-args v)))))])
3536

3637
(struct class-combinator combinator (opaque absents)
38+
#:authentic
3739
#:transparent
3840
#:property prop:combinator-name "class/sc"
3941
#:methods gen:sc
@@ -52,6 +54,7 @@
5254
(merge-restricts* 'impersonator (map f (member-seq->list (combinator-args v)))))])
5355

5456
(struct instanceof-combinator combinator ()
57+
#:authentic
5558
#:transparent
5659
#:property prop:combinator-name "instanceof/sc"
5760
#:methods gen:sc
@@ -78,8 +81,9 @@
7881
(filter-map member-spec-sc vals)]))
7982

8083
(struct member-seq (vals)
81-
#:transparent
82-
#:property prop:sequence member-seq->list)
84+
#:authentic
85+
#:transparent
86+
#:property prop:sequence member-seq->list)
8387

8488
(define (member-seq-sc-map f seq)
8589
(match seq

typed-racket-lib/typed-racket/static-contracts/combinators/parametric.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
[sealing-var/sc (identifier? . -> . static-contract?)])
3232

3333
(struct parametric-combinator combinator (vars)
34+
#:authentic
3435
#:transparent
3536
#:property prop:combinator-name "parametric->/sc"
3637
#:methods gen:sc
@@ -66,6 +67,7 @@
6667

6768
;; combinator for sealing-> contracts for row polymorphism
6869
(struct sealing-combinator combinator (vars members)
70+
#:authentic
6971
#:transparent
7072
#:property prop:combinator-name "sealing->/sc"
7173
#:methods gen:sc

typed-racket-lib/typed-racket/static-contracts/combinators/prefab.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
(struct prefab-combinator combinator (key field-mutability)
2222
#:transparent
23+
#:authentic
2324
#:property prop:combinator-name "prefab/sc"
2425
#:methods gen:sc
2526
[(define (sc-map v f)

typed-racket-lib/typed-racket/static-contracts/combinators/proposition.rkt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
(provide-for-cond-contract proposition-contract?)
1515

16-
(struct proposition-contract static-contract () #:transparent)
16+
(struct proposition-contract static-contract () #:transparent #:authentic)
1717

1818

1919
(define/match (flat-lambda-write v port mode)
@@ -54,6 +54,7 @@
5454
;; in the contract syntax they generate.
5555
(struct flat-named-lambda/sc static-contract (name arg body)
5656
#:transparent
57+
#:authentic
5758
#:methods gen:sc
5859
[(define/match (sc-map v f)
5960
[((flat-named-lambda/sc name arg body) f)
@@ -88,6 +89,7 @@
8889
;; so we can use it directly as a predicate.
8990
(struct is-flat-type/sc proposition-contract (obj type)
9091
#:transparent
92+
#:authentic
9193
#:methods gen:sc
9294
[(define/match (sc-map v f)
9395
[((is-flat-type/sc obj type) f)
@@ -112,6 +114,7 @@
112114
;; See is-flat-type/sc for more details.
113115
(struct not-flat-type/sc proposition-contract (obj type)
114116
#:transparent
117+
#:authentic
115118
#:methods gen:sc
116119
[(define/match (sc-map v f)
117120
[((not-flat-type/sc obj type) f)
@@ -135,6 +138,7 @@
135138
;; flat-named-lambda/sc.
136139
(struct leq/sc proposition-contract (lhs rhs)
137140
#:transparent
141+
#:authentic
138142
#:methods gen:sc
139143
[(define/match (sc-map v f)
140144
[((leq/sc lhs rhs) f)
@@ -152,6 +156,7 @@
152156

153157
(struct and-prop/sc proposition-contract (args)
154158
#:transparent
159+
#:authentic
155160
#:methods gen:sc
156161
[(define/match (sc-map v f)
157162
[((and-prop/sc args) f)
@@ -172,6 +177,7 @@
172177

173178
(struct or-prop/sc proposition-contract (args)
174179
#:transparent
180+
#:authentic
175181
#:methods gen:sc
176182
[(define/match (sc-map v f)
177183
[((or-prop/sc args) f)

typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
(equal?/recur s1 s2 stx-equal?))]))
4444

4545
(struct simple-contract static-contract (syntax kind name)
46+
#:authentic
4647
#:transparent
4748
#:methods gen:equal+hash
4849
[(define (equal-proc s1 s2 recur)

typed-racket-lib/typed-racket/static-contracts/combinators/struct.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
[struct-type/sc (any/c . -> . static-contract?)])
2323

2424
(struct struct-combinator combinator (name mut?)
25+
#:authentic
2526
#:transparent
2627
#:property prop:combinator-name "struct/sc"
2728
#:methods gen:sc
@@ -61,6 +62,7 @@
6162
;; reflective use.
6263
(struct struct-type/sc combinator ()
6364
#:transparent
65+
#:authentic
6466
#:property prop:combinator-name "struct-type/sc"
6567
#:methods gen:sc
6668
[(define (sc-map v f)

typed-racket-lib/typed-racket/static-contracts/combinators/structural.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
[(_ sc:static-combinator-form c:expr kind:contract-category-keyword)
114114
#'(begin
115115
(struct sc.struct-name combinator ()
116+
#:authentic
116117
#:transparent
117118
#:methods gen:sc
118119
[(define sc-map sc.map)

typed-racket-lib/typed-racket/static-contracts/combinators/symbolic-object.rkt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
(provide-for-cond-contract symbolic-object-contract?)
1515

16-
(struct symbolic-object-contract static-contract () #:transparent)
16+
(struct symbolic-object-contract static-contract () #:transparent #:authentic)
1717

1818
;; an identifier symbolic object e.g. x
1919
(struct id/sc symbolic-object-contract (syntax)
20+
#:authentic
2021
#:transparent
2122
#:methods gen:equal+hash
2223
[(define/match (equal-proc a b rec)
@@ -35,6 +36,7 @@
3536

3637
;; a path element access into a symbolic object e.g. (car o)
3738
(struct acc-obj/sc symbolic-object-contract (acc-stx obj)
39+
#:authentic
3840
#:transparent
3941
#:methods gen:equal+hash
4042
[(define/match (equal-proc a b recur)
@@ -58,6 +60,7 @@
5860

5961
;; a linear expression symbolic obj, e.g. 42, or x, or (+ 1 (* 2 y)), etc...
6062
(struct linear-exp/sc symbolic-object-contract (const terms)
63+
#:authentic
6164
#:transparent
6265
#:methods gen:sc
6366
[(define/match (sc-map v f)

typed-racket-lib/typed-racket/static-contracts/combinators/unit.rkt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
(for-template racket/base racket/unit)
1111
(for-syntax racket/base syntax/parse))
1212

13-
(struct signature-spec (name members scs) #:transparent)
13+
(struct signature-spec (name members scs) #:transparent #:authentic)
1414

1515
(struct unit-combinator combinator ()
16+
#:authentic
1617
#:transparent
1718
#:property prop:combinator-name "unit/sc"
1819
#:methods gen:sc
@@ -40,6 +41,7 @@
4041
(filter-map (lambda (x) x) invoke)))]))
4142

4243
(struct unit-spec (imports exports init-depends invoke)
44+
#:authentic
4345
#:transparent
4446
#:property prop:sequence unit-spec->list)
4547

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
; equations: (hash/c var? (-> value?))
2525
; initial-values: (hash/c var? (-> value?))
26-
(struct equation-set (equations initial-values))
26+
(struct equation-set (equations initial-values) #:transparent #:authentic)
2727

2828
(define (make-equation-set)
2929
(equation-set (make-hasheq) (make-hasheq)))

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@
111111

112112
;; Super struct of static contracts
113113
(struct static-contract ()
114-
#:transparent
115-
#:property prop:custom-print-quotable 'never)
114+
#:transparent
115+
#:property prop:custom-print-quotable 'never
116+
#:authentic)
116117

117118
;; Represents a recursive contract.
118119
;; In each value and the body, each name is bound to a the corresponding value contract.
@@ -121,6 +122,7 @@
121122
;; - body : static-contract?
122123
;; names and value must have the same length.
123124
(struct recursive-sc static-contract (names values body)
125+
#:authentic
124126
#:transparent
125127
#:methods gen:sc
126128
[(define (sc-map v f)
@@ -140,6 +142,7 @@
140142
;; A use of a contract bound by recursive-sc
141143
;; - name : identifier?
142144
(struct recursive-sc-use static-contract (name)
145+
#:authentic
143146
#:transparent
144147
#:methods gen:sc
145148
[(define (sc-map v f) v)
@@ -152,6 +155,7 @@
152155
;; Provides printing functionality.
153156
;; - args : (sequenceof static-contract?)
154157
(struct combinator static-contract (args)
158+
#:authentic
155159
#:transparent
156160
#:property prop:combinator-name "combinator/sc"
157161
#:methods gen:custom-write [(define write-proc combinator-write-proc)])

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
[(_ name:id (args:id ...) kind:kind-keyword p:printer body:expr)
3535
#'(struct name static-contract (args ...)
3636
#:transparent
37+
#:authentic
3738
p.methods ...
3839
#:methods gen:sc
3940
[(define (sc-map v f) v)

0 commit comments

Comments
 (0)