On this page:
define/ contract
box/ c
vectorof
vector/ c
struct/ c

 (require mzlib/contract)

This library is designed as a backwards compatible library for old uses of contracts. It should not be used for new libraries; use scheme/contract instead.

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 scheme/contract:

  

</c

  

flat-rec-contract

  

<=/c

  

guilty-party

  

=/c

  

integer-in

  

>/c

  

list/c

  

>=/c

  

listof

  

and/c

  

make-none/c

  

any

  

make-proj-contract

  

any/c

  

natural-number/c

  

between/c

  

none/c

  

box-immutable/c

  

not/c

  

build-compound-type-name

  

one-of/c

  

coerce-contract

  

or/c

  

cons/c

  

parameter/c

  

contract

  

printable/c

  

contract-first-order-passes?

  

promise/c

  

contract-violation->string

  

provide/contract

  

contract?

  

raise-contract-error

  

define-contract-struct

  

real-in

  

false/c

  

recursive-contract

  

flat-contract

  

string/len

  

flat-contract-predicate

  

symbols

  

flat-contract?

  

syntax/c

  

flat-murec-contract

  

vector-immutable/c

  

flat-named-contract

  

vector-immutableof

It also provides the old version of the following forms:

(define/contract id contract-expr init-value-expr)
Attaches the contract contract-expr to init-value-expr and binds that to id.

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.

(box/c c)  flat-contract?
  c : flat-contract?
Returns a flat contract that recognizes boxes. The content of the box must match c.

Accepts a flat contract and returns a flat contract that checks for vectors whose elements match the original contract.

(vector/c c ...)  flat-contract?
  c : flat-contract?
Accepts any number of flat contracts 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.

(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.