This chapter provides a gentle introduction to Racketβs contract system.
+Contracts in The Racket Reference provides more on contracts.
7.1Contracts and Boundaries
7.1.1Contract Violations
7.1.2Experimenting with Contracts and Modules
7.1.3Experimenting with Nested Contract Boundaries
7.2Simple Contracts on Functions
7.2.1Styles of ->
7.2.2Using define/contract and ->
7.2.3any and any/c
7.2.4Rolling Your Own Contracts
7.2.5Contracts on Higher-order Functions
7.2.6Contract Messages with β???β
7.2.7Dissecting a contract error message
7.3Contracts on Functions in General
7.3.1Optional Arguments
7.3.2Rest Arguments
7.3.3Keyword Arguments
7.3.4Optional Keyword Arguments
7.3.5Contracts for case-lambda
7.3.6Argument and Result Dependencies
7.3.7Checking State Changes
7.3.8Multiple Result Values
7.3.9Fixed but Statically Unknown Arities
7.4Contracts: A Thorough Example
7.5Contracts on Structures
7.5.1Guarantees for a Specific Value
7.5.2Guarantees for All Values
7.5.3Checking Properties of Data Structures
7.6Abstract Contracts using #:exists and #:β
7.7Additional Examples
7.7.1A Customer-Manager Component
7.7.2A Parameteric (Simple) Stack
7.7.3A Dictionary
7.7.4A Queue
7.8Building New Contracts
7.8.1Contract Struct Properties
7.8.2With all the Bells and Whistles
7.9Gotchas
7.9.1Contracts and eq?
7.9.2Contract boundaries and define/contract
7.9.3Exists Contracts and Predicates
7.9.4Defining Recursive Contracts
7.9.5Mixing set! and contract-out
AltStyle γ«γγ£γ¦ε€ζγγγγγΌγΈ (->γͺγͺγΈγγ«) / γ’γγ¬γΉ: γ’γΌγ: γγγ©γ«γ ι³ε£°γγ©γ¦γΆ γ«γδ»γ ι θ²εθ»’ ζεζ‘ε€§ γ’γγ€γ«