8 Contracts (original) (raw)

8 Contracts🔗

+Contracts in The Racket Guide introduces contracts.

The contract system guards one part of a program from another. Programmers specify the behavior of a module’s exports via(provide (contract-out ....)) or (require (contract-in ...)), and the contract system enforces those constraints.

Contracts come in two forms: those constructed by the various operations listed in this section of the manual, and various ordinary Racket values that double as contracts, including

Contract combinators are functions such as -> andlistof that take contracts and produce other contracts.

Contracts in Racket are subdivided into three different categories:

For more about this hierarchy, see the section “Impersonators and Chaperones” as well as a research paper [Strickland12] on chaperones, impersonators, and how they can be used to implement contracts.

Changed in version 6.1.1.8 of package base: Changed +nan.0 and +nan.f to be equal?-based contracts.

8.1 Data-structure Contracts
8.2 Function Contracts
8.3 Parametric Contracts
8.4 Lazy Data-structure Contracts
8.5 Structure Type Property Contracts
8.6 Attaching Contracts to Values
8.6.1 Nested Contract Boundaries
8.6.2 Low-level Contract Boundaries
8.7 Building New Contract Combinators
8.7.1 Blame Objects
8.7.2 Contracts as structs
8.7.3 Obligation Information in Check Syntax
8.7.4 Utilities for Building New Combinators
8.8 Contract Utilities
8.9 racket/contract/base
8.10 Collapsible Contracts
8.11 Legacy Contracts
8.12 Random generation