On this page:
contract-struct
define-contract-struct

8.4 Lazy Data-structure Contracts

syntax

(contract-struct id (field-id ...))

NOTE: This library is deprecated; use struct, instead. Lazy struct contracts no longer require a separate struct declaration; instead struct/dc and struct/c work directly with struct and define-struct.

Like struct, but with two differences: they do not define field mutators, and they define two contract constructors: id/c and id/dc. The first is a procedure that accepts as many arguments as there are fields and returns a contract for struct values whose fields match the arguments. The second is a syntactic form that also produces contracts on the structs, but the contracts on later fields may depend on the values of earlier fields.

The generated contract combinators are lazy: they only verify the contract holds for the portion of some data structure that is actually inspected. More precisely, a lazy data structure contract is not checked until a selector extracts a field of a struct.

(id/dc field-spec ...)
 
field-spec = [field-id contract-expr]
  | [field-id (field-id ...) contract-expr]

In each field-spec case, the first field-id specifies which field the contract applies to; the fields must be specified in the same order as the original contract-struct. The first case is for when the contract on the field does not depend on the value of any other field. The second case is for when the contract on the field does depend on some other fields, and the parenthesized field-ids indicate which fields it depends on; these dependencies can only be to earlier fields.

syntax

(define-contract-struct id (field-id ...))

NOTE: This library is deprecated; use struct, instead. Lazy struct contracts no longer require a separate struct declaration; instead struct/dc and struct/c work directly with struct and define-struct.

Like contract-struct, but where the constructor’s name is make-id, much like define-struct.