► |  | The Racket Reference

1 | Language Model
2 | Notation for Documentation
3 | Syntactic Forms
4 | Datatypes
5 | Structures
6 | Classes and Objects
7 | Units
8 | Contracts
9 | Pattern Matching
10 | Control Flow
11 | Concurrency and Parallelism
12 | Macros
13 | Input and Output
14 | Reflection and Security
15 | Operating System
16 | Memory Management
17 | Unsafe Operations
18 | Running Racket
| Bibliography
| Index

▼ | 8 | 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.7 | Building New Contract Combinators
8.8 | Contract Utilities
8.9 | racket/ contract/ base
8.10 | Collapsible Contracts
8.11 | Legacy Contracts
8.12 | Random generation

On this page:

make-proj-contract
raise-contract-error
contract-proc

top ← prev up next →

#### 8.11`` Legacy Contracts

> > procedure

> > (make-proj-contract name proj first-order) → contract?

> name : any/c

> proj

> :

> (or/c (-> any/c
> any/c
> (list/c any/c any/c)
> contact?
> (-> any/c any/c))
> (-> any/c
> any/c
> (list/c any/c any/c)
> contact?
> boolean?
> (-> any/c any/c)))

> first-order : (-> any/c boolean?)

Builds a contract using an old interface.

Modulo errors, it is equivalent to:

> (make-contract
> #:name name
> #:first-order first-order
> #:projection
> (cond
> [(procedure-arity-includes? proj 5)
> (lambda (blame)
> (proj (blame-positive blame)
> (blame-negative blame)
> (list (blame-source blame) (blame-value blame))
> (blame-contract blame)
> (not (blame-swapped? blame))))]
> [(procedure-arity-includes? proj 4)
> (lambda (blame)
> (proj (blame-positive blame)
> (blame-negative blame)
> (list (blame-source blame) (blame-value blame))
> (blame-contract blame)))]))

> > procedure

> > (raise-contract-error |  | val |  |  |  |
> > |  | src |  |  |  |
> > |  | pos |  |  |  |
> > |  | name |  |  |  |
> > |  | fmt |  |  |  |
> > |  | arg ...) |  | → |  | any/c

> val : any/c
> src : any/c
> pos : any/c
> name : any/c
> fmt : string?
> arg : any/c

Calls raise-blame-error after building a blame struct from the val, src, pos, and name arguments. The fmt string and following arguments are passed to format and used as the string in the error message.

> > procedure

> > (contract-proc c)

> →

> (->* (symbol? symbol? (or/c syntax? (list/c any/c any/c)))
> (boolean?)
> (-> any/c any))

> c : contract?

Constructs an old-style projection from a contract.

The resulting function accepts the information that is in a blame struct and returns a projection function that checks the contract.

top ← prev up next →