8.11 Legacy Contracts (original) (raw)
top contents [← prev](collapsible.html "backward to "8.10 Collapsible Contracts"") [up](contracts.html "up to "8 Contracts"") [next →](Random%5Fgeneration.html "forward to "8.12 Random generation"")
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 toformat 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 blamestruct and returns a projection function that checks the contract.
top contents [← prev](collapsible.html "backward to "8.10 Collapsible Contracts"") [up](contracts.html "up to "8 Contracts"") [next →](Random%5Fgeneration.html "forward to "8.12 Random generation"")