The contract system guards one part of a program from another. Programmers specify the behavior of a module’s exports via (provide (contract-out ....)), and the contract system enforces those constraints.
predicates: any procedure of arity 1 is treated as a predicate. During contract checking, it is applied to the values that appear and should return #f to indicate that the contract failed, and anything else to indicate it passed.
Flat contracts can be fully checked immediately for a given value. These kinds of contracts are essentially predicate functions. Using flat-contract-predicate, you can extract the predicate from an arbitrary flat contract; some flat contracts can be applied like functions, in which case they accept a single argument and return #t or #f to indicate if the given value would be accepted by the contract. All of the flat contracts returned by functions in this library can be used directly as predicates, but ordinary Racket values that double as flat contracts (e.g., numbers or symbols) cannot.
The function flat-contract? recognizes a flat contract.
Chaperone contracts are not always immediately checkable, but are guaranteed to not change any properties of any values that they check. That is, they may wrap a value in such a way that it signals contract violations later, as the value is used (e.g., a function contract checks the inputs and outputs to the function only when the function is called and returned), but any properties that the value had before being wrapped by the contract are preserved by the contract wrapper.
All contracts are impersonator contracts.
Changed in version 126.96.36.199 of package base: Changed +nan.0 and +nan.f to be equal?-based contracts.