(require mzlib/contract) | package: compatibility-lib |
NOTE: This library is deprecated; use racket/contract, instead. This library is designed as a backwards compatible library for old uses of contracts. It should not be used for new libraries.
The main differences: the function contract syntax is more regular and function contracts now support keywords, and union is now or/c.
The mzlib/contract library re-exports many bindings from racket/contract:
|
| ||
|
| guilty-party | |
|
| ||
|
| ||
|
| ||
|
| ||
|
| make-proj-contract | |
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
| contract-violation->string |
| |
|
| raise-contract-error | |
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
|
It also provides the old version of the following contracts:
syntax
(define/contract id contract-expr init-value-expr)
The define/contract form treats individual definitions as units of blame. The definition itself is responsible for positive (co-variant) positions of the contract and each reference to id (including those in the initial value expression) must meet the negative positions of the contract.
Error messages with define/contract are not as clear as those provided by provide/contract, because define/contract cannot detect the name of the definition where the reference to the defined variable occurs. Instead, it uses the source location of the reference to the variable as the name of that definition.
procedure
(box/c c) → flat-contract?
c : flat-contract?
procedure
(vectorof c) → flat-contract?
c : flat-contract?
procedure
(vector/c c ...) → flat-contract?
c : flat-contract?
syntax
(struct/c struct-id flat-contract-expr ...)
procedure
(build-flat-contract name predicate) → flat-contract?
name : symbol? predicate : (-> any/c any)
syntax
(->* (contract-dom-expr ...) ->*rng)
(->* (contract-dom-expr ...) contract-rest-expr ->*rng)
->*rng = (contract-rng-expr ...) | any
(->* (contract-dom-expr ...) (contract-rng-expr ...)) = (-> contract-dom-expr ... (values contract-rng-expr))
(->* (contract-expr ...) contract-rest-expr any) = (->* (contract-expr ...) #:rest contract-rest-expr any)
(->* (contract-expr ...) contract-rest-expr (contract-rng-expr ...)) = (->* (contract-expr ...) #:rest contract-rest-expr (values contract-rng-expr ...))
syntax
(opt-> (contract-req-expr ...) (contact-opt-expr ...) any)
(opt-> (contract-req-expr ...) (contact-opt-expr ...) contract-rng-expr)
syntax
(opt->* (contract-req-expr ...) (contact-opt-expr ...) any)
(opt->* (contract-req-expr ...) (contact-opt-expr ...) (contract-rng-expr ...))
(opt->* (contract-req-expr ...) (contract-opt-expr ...) any) = (->* (contract-req-expr ...) (contract-opt-expr ...) any)
(opt->* (contract-req-expr ...) (contract-opt-expr ...) (contract-rng-expr ...)) = (->* (contract-req-expr ...) (contract-opt-expr ...) (values contract-rng-expr ...))
syntax
(->d contract-dom-expr ... contract-rng-fun-expr)
syntax
(->d* (contract-dom-expr ...) contract-rng-fun-expr)
(->d* (contract-dom-expr ...) contract-rest-expr contract-rng-fun-expr)
In the two sub-expression case, the first sequence of contracts are contracts on the domain of the function and the second subexpression is expected to evaluate to a function that accepts as many arguments as there are expressions in the first position. It should return multiple values: one contract for each result of the function.
In the three sub-expression case, the first and last subexpressions are just like the sub-expressions in the two sub-expression case; the middle sub-expression si expected to evaluate to a contract on the rest argument.
syntax
(->r ([dom-x contract-dom-expr] ...) rng)
(->r ([dom-x contract-dom-expr] ...) rest-x contract-rest-expr rng)
rng = any | (values contract-expr ...) | contract-expr
syntax
(->pp ([dom-x contract-dom-expr] ...) pre-cond-expr any)
(->pp ([dom-x contract-dom-expr] ...) pre-cond-expr (values [rng-x contract-rng-expr] ...) post-cond-expr)
(->pp ([dom-x contract-dom-expr] ...) pre-cond-expr contract-rng-expr rng-x post-cond-expr)
syntax
(->pp-rest ([dom-x contract-dom-expr] ...) rest-x rest-contract-expr pre-cond-expr any)
(->pp-rest ([dom-x contract-dom-expr] ...) rest-x rest-contract-expr pre-cond-expr (values [rng-x contract-rng-expr] ...) post-cond-expr)
(->pp-rest ([dom-x contract-dom-expr] ...) rest-x rest-contract-expr pre-cond-expr contract-rng-expr rng-x post-cond-expr)
syntax
(case-> mzlib/contract-arrow-contract-expr ...)
syntax
(object-contract [id mzlib/contract-arrow-contract-expr] ...)