Constructs a flat contract from predicate. A value satisfies the contract if the predicate returns a true value.
type-name : string?
Like flat-contract, but the first argument must be a string used for error reporting. The string describes the type that the predicate checks for.
A flat contract that accepts any value.
A flat contract that accepts no values.
Takes any number of predicates and higher-order contracts and returns a contract that accepts any value that any one of the contracts accepts, individually.
If all of the arguments are procedures or flat contracts, the result is a flat contract. If only one of the arguments is a higher-order contract, the result is a contract that just checks the flat contracts and, if they don’t pass, applies the higher-order contract.
If there are multiple higher-order contracts, or/c uses contract-first-order-passes? to distinguish between them. More precisely, when an or/c is checked, it first checks all of the flat contracts. If none of them pass, it calls contract-first-order-passes? with each of the higher-order contracts. If only one returns true, or/c uses that contract. If none of them return true, it signals a contract violation. If more than one returns true, it signals an error indicating that the or/c contract is malformed.
Takes any number of contracts and returns a contract that checks that accepts any value that satisfies all of the contracts, simultaneously.
The contract produced by and/c tests any value by applying the contracts in order, from left to right.
Accepts a flat contracts or a predicate and returns a flat contract that checks the inverse of the argument.
z : number?
Returns a flat contract that requires the input to be a number and = to z.
n : real?
Returns a flat contract that requires the input to be a number and < to n.
n : number?
n : number?
n : number?
n : number?
m : number?
Returns a flat contract that requires the input to be a between n and m or equal to one of them.
n : real?
m : real?
Returns a flat contract that requires the input to be a real number between n and m, inclusive.
j : exact-integer?
k : exact-integer?
Returns a flat contract that requires the input to be an exact integer between j and k, inclusive.
A flat contract that requires the input to be an exact non-negative integer.
len : nonnegative-exact-integer?
Returns a flat contract that recognizes strings that have fewer than len characters.
A flat contract that recognizes #f.
v : any/c
Accepts any number of atomic values and returns a flat contract that recognizes those values, using eqv? as the comparison predicate. For the purposes of one-of/c, atomic values are defined to be: characters, symbols, booleans, null keywords, numbers, void, and undefined.
sym : symbol?
Accepts any number of symbols and returns a flat contract that recognizes those symbols.
Accepts any number of flat contracts (or predicates that are converted to flat contracts via flat-contract) and returns a flat-contract that recognizes vectors. The number of elements in the vector must match the number of arguments supplied to vector/c, and each element of the vector must match the corresponding flat contract.
Returns a flat-contract that recognizes boxes. The content of the box must match c.
Returns a contract that recognizes a list whose every element matches the contract c. Beware that when this contract is applied to a value, the result is not necessarily eq? to the input.
car-c : contract?
cdr-c : contract?
Produces a contract the recognizes pairs first and second elements match car-c and cdr-c, respectively. Beware that when this contract is applied to a value, the result is not necessarily eq? to the input.
Produces a contract for a list. The number of elements in the list must match the number of arguments supplied to list/c, and each element of the list must match the corresponding contract. Beware that when this contract is applied to a value, the result is not necessarily eq? to the input.
c : flat-contract?
Produces a flat contract that recognizes syntax objects whose syntax-e content matches c.
(struct/c struct-id flat-contract-expr )
Produces a flat contract that recognizes instances of the structure type named by struct-id, and whose field values match the flat contracts produced by the flat-contract-exprs.
c : contract?
Produces a contract on parameters whose values must match contract.
(flat-rec-contract id flat-contract-expr )
Constructs a recursive flat contract. A flat-contract-expr can refer to id to refer recursively to the generated contract.
For example, the contract
(cons/c sexp sexp)
is a flat contract that checks for (a limited form of) S-expressions. It says that an sexp is either two sexp combined with cons, or a number, or a symbol.
Note that if the contract is applied to a circular value, contract checking will not terminate.}
(flat-murec-contract ([id flat-contract-expr ] ) body )
A generalization of flat-rec-contracts for defining several mutually recursive flat contracts simultaneously. Each id is visible in the entire flat-murec-contract form, and the result of the final body is the result of the entire form.
Constructs a contract on a promise. The contract does not force the promise, but when the promise is forced, the contract checks that the result value meets the contract produced by expr.