@@ -21,7 +21,7 @@ currently supported in Typed Racket.
21
21
@section{Types}
22
22
23
23
@defform[#:kind "type "
24
- (Con [in type] [out type])]{
24
+ (Contract [in type] [out type])]{
25
25
A contract can only be attached to values that satisfy its @racket[in] type,
26
26
just like how a function can only be applied to arguments that satisfy its
27
27
domain type. Attaching a contract with output type @racket[out] to a value
@@ -32,72 +32,72 @@ currently supported in Typed Racket.
32
32
to the precision order, which is like the subtype order. It differs in that it
33
33
lacks contravariance in negative positions such as function domains.
34
34
35
- @racket[Con ] is the most general type for contracts.
35
+ @racket[Contract ] is the most general type for contracts.
36
36
}
37
37
38
38
@defform[#:kind "type "
39
- (FlatCon [in type] [out type])]{
40
- This type is like @racket[Con ] but corresponds to @tech{flat contracts}. All
41
- @racket[FlatCon] contracts have a corresponding @racket[Con ] type. For
42
- example, a @racket[(FlatCon Real Real)] is also a @racket[(Con Real Real)].
39
+ (FlatContract [in type] [out type])]{
40
+ This type is like @racket[Contract ] but corresponds to @tech{flat contracts}. All
41
+ @racket[FlatCon] contracts have a corresponding @racket[Contract ] type. For
42
+ example, a @racket[(FlatContract Real Real)] is also a @racket[(Contract Real Real)].
43
43
44
44
A contract with @racket[FlatCon] type can be used as a function having domain
45
45
type @racket[in].
46
46
47
47
Ordinary Racket @tech[#:key "contracts " ]{values coercible to a contract }, such
48
48
as integers, do not have this type. Coercing such values of type @racket[T] to
49
49
a contract , as Racket's contract attachment forms automatically do , produces a
50
- value of type @racket[(FlatCon Any T)].
50
+ value of type @racket[(FlatContract Any T)].
51
51
}
52
52
53
53
@section{Data-structure Contracts}
54
54
55
55
@deftogether[(@defproc[(flat-named-contract [name Any]
56
- [c (FlatCon a b)])
57
- (FlatCon a b)]
58
- @defthing[any/c (FlatCon Any Any)]
59
- @defthing[none/c (FlatCon Any Any)]
60
- @defproc[(not/c [c (FlatCon a b)])
61
- (FlatCon a b)]
62
- @defproc*[([(=/c [n Natural]) (FlatCon Any Natural)]
63
- [(=/c [z Integer]) (FlatCon Any Integer)]
64
- [(=/c [r Real]) (FlatCon Any Real)])]
65
- @defproc[(</c [r Real]) (FlatCon Any Real)]
66
- @defproc[(>/c [r Real]) (FlatCon Any Real)]
67
- @defproc[(<=/c [r Real]) (FlatCon Any Real)]
68
- @defproc[(>=/c [r Real]) (FlatCon Any Real)]
69
- @defproc[(between/c [lo Real] [hi Real]) (FlatCon Any Real)]
70
- @defproc[(real-in [lo Real] [hi Real]) (FlatCon Any Real)]
56
+ [c (FlatContract a b)])
57
+ (FlatContract a b)]
58
+ @defthing[any/c (FlatContract Any Any)]
59
+ @defthing[none/c (FlatContract Any Any)]
60
+ @defproc[(not/c [c (FlatContract a b)])
61
+ (FlatContract a b)]
62
+ @defproc*[([(=/c [n Natural]) (FlatContract Any Natural)]
63
+ [(=/c [z Integer]) (FlatContract Any Integer)]
64
+ [(=/c [r Real]) (FlatContract Any Real)])]
65
+ @defproc[(</c [r Real]) (FlatContract Any Real)]
66
+ @defproc[(>/c [r Real]) (FlatContract Any Real)]
67
+ @defproc[(<=/c [r Real]) (FlatContract Any Real)]
68
+ @defproc[(>=/c [r Real]) (FlatContract Any Real)]
69
+ @defproc[(between/c [lo Real] [hi Real]) (FlatContract Any Real)]
70
+ @defproc[(real-in [lo Real] [hi Real]) (FlatContract Any Real)]
71
71
@defproc*[([(integer-in [lo Positive-Integer] [hi Integer])
72
- (FlatCon Any Positive-Integer)]
72
+ (FlatContract Any Positive-Integer)]
73
73
[(integer-in [lo Natural] [hi Integer])
74
- (FlatCon Any Natural)]
74
+ (FlatContract Any Natural)]
75
75
[(integer-in [lo Integer] [hi Integer])
76
- (FlatCon Any Integer)])]
77
- @defthing[natural-number/c (FlatCon Any Natural)]
76
+ (FlatContract Any Integer)])]
77
+ @defthing[natural-number/c (FlatContract Any Natural)]
78
78
@defproc[(string-len/c [len Real])
79
- (FlatCon Any String)]
80
- @defthing[false/c (Con Any False)]
81
- @defthing[printable/c (FlatCon Any Any)]
82
- @defproc[(listof [c (Con a b)])
83
- (Con (Listof a) (Listof b))]
84
- @defproc[(non-empty-listof [c (Con a b)])
85
- (Con (Listof a) (Pairof b (Listof b)))]
86
- @defproc[(list*of [c (Con a b)])
87
- (Con (Rec x (Pairof a (U a x)))
79
+ (FlatContract Any String)]
80
+ @defthing[false/c (Contract Any False)]
81
+ @defthing[printable/c (FlatContract Any Any)]
82
+ @defproc[(listof [c (Contract a b)])
83
+ (Contract (Listof a) (Listof b))]
84
+ @defproc[(non-empty-listof [c (Contract a b)])
85
+ (Contract (Listof a) (Pairof b (Listof b)))]
86
+ @defproc[(list*of [c (Contract a b)])
87
+ (Contract (Rec x (Pairof a (U a x)))
88
88
(Rec x (Pairof b (U b x))))]
89
- @defproc[(cons/c [car-c (Con a b)]
90
- [cdr-c (Con c d)])
91
- (Con Any (Pairof b d))]
92
- @defproc[(syntax/c [c (FlatCon a b)])
93
- (FlatCon (Syntaxof a) (Syntaxof b))]
94
- @defproc*[([(parameter/c [c (Con a b)])
95
- (Con (Parameter b) (Parameter b))]
96
- [(parameter/c [in-c (Con a b)]
97
- [out-c (Con c d)])
98
- (Con (Parameter b d) (Parameter b d))])]
89
+ @defproc[(cons/c [car-c (Contract a b)]
90
+ [cdr-c (Contract c d)])
91
+ (Contract Any (Pairof b d))]
92
+ @defproc[(syntax/c [c (FlatContract a b)])
93
+ (FlatContract (Syntaxof a) (Syntaxof b))]
94
+ @defproc*[([(parameter/c [c (Contract a b)])
95
+ (Contract (Parameter b) (Parameter b))]
96
+ [(parameter/c [in-c (Contract a b)]
97
+ [out-c (Contract c d)])
98
+ (Contract (Parameter b d) (Parameter b d))])]
99
99
@defproc[(symbols [sym Symbol] ...+)
100
- (Con Any Symbol)])]{
100
+ (Contract Any Symbol)])]{
101
101
These forms are typed versions of those found in Racket. They are otherwise
102
102
the same.
103
103
}
@@ -153,5 +153,5 @@ library is a work in progress.
153
153
@item{Contract types do not have any contract compilation/runtime enforcement.}
154
154
@item{Racket's built-in combinators for vectors, boxes, hashes are unsupported.}
155
155
@item{Values that pass @racket[flat-contract?] are not necessarily members of
156
- the @racket[FlatCon ] type: members of that type can be used in function
156
+ the @racket[FlatContract ] type: members of that type can be used in function
157
157
position, but @racket[flat-contract?] returns true for non-predicates.}]
0 commit comments