▼ |  | Unstable: May Change Without Warning

1 | Guidelines for Developing unstable Libraries
2 | Automata: Compiling State Machines
3 | Bytes
4 | Contracts
5 | Contracts for Macro Subexpressions
6 | Debugging
7 | Definitions
8 | Errors
9 | Futures
10 | Functions
11 | Hash Tables
12 | Interface-Oriented Programming for Classes
13 | Lazy Require
14 | Lists
15 | Logging
16 | Macro Testing
17 | Mark Parameters
18 | Match
19 | Open place expressions
20 | Option Contracts
21 | Parameter Groups
22 | Pretty-Printing
23 | Re-Contracting Identifiers
24 | Sandbox
25 | Sequences
26 | Strings
27 | Structs
28 | Struct Printing
29 | Syntax
30 | Temporal Contracts: Explicit Contract Monitors
31 | Unix Domain Sockets
32 | 2D Syntax

On this page:

recontract-out

6.1.1
top ← prev up next →

### 23`` Re-Contracting Identifiers

Ryan Culpepper <ryanc@racket-lang.org>

This library is unstable; compatibility will not be maintained. See Unstable: May Change Without Warning for more information.

(require unstable/recontract) | package: unstable-lib

> syntax (recontract-out id ...)

Provides each id with its existing contract, but changes the positive blame party of the contract to the enclosing module, instead of the module that originally attached the contract to id. Each id must be imported from a module that exports it via contract-out or recontract-out; otherwise a syntax error is raised.

Use recontract-out when you want to use the same contracts both between different parts of a library and between the library and its clients. The library should use recontract-out in the public interface modules so that clients do not see references to private implementation modules in contract errors.

Examples:
> > (module private racket
> (define (f x) (if (positive? x) x 'wrong))
> (provide (contract-out [f (-> real? real?)])))
> > (module public racket
> (require 'private unstable/recontract)
> (provide (recontract-out f)))
> > (require 'public)
> > (f 1)
> 1
> > (f -2)
> f: broke its contract
> promised: real?
> produced: 'wrong
> in: the range of
> (-> real? real?)
> contract from: public
> blaming: public
> (assuming the contract is correct)
> at: eval:3.0
> > (f 'apple)
> f: contract violation
> expected: real?
> given: 'apple
> in: the 1st argument of
> (-> real? real?)
> contract from: public
> blaming: top-level
> (assuming the contract is correct)
> at: eval:3.0

top ← prev up next →