procedure
v:any/c
procedure
v:any/c
procedure
( flat-contract? v)→boolean?
v:any/c
For example, flat-contract constructs flat contracts from predicates, and symbols, booleans, numbers, and other ordinary Racket values (that are defined as contracts) are also flat contracts.
procedure
( list-contract? v)→boolean?
v:any/c
A list contract is one that insists that its argument is a list? , meaning that the value cannot be cyclic and must either be the empty list or a pair constructed with cons and another list.
Added in version 6.0.1.13 of package base.
procedure
( contract-name c)→any/c
procedure
( value-contract v)→(or/c contract? #f)
To support value-contract and value-contract in your own contract combinators, use prop:contracted or impersonator-prop:contracted .
procedure
( has-contract? v)→boolean?
v:any/c
procedure
( value-blame v)→(or/c blame? #f)
To support value-contract and value-blame in your own contract combinators, use prop:blame or impersonator-prop:blame .
Added in version 6.0.1.12 of package base.
procedure
( has-blame? v)→boolean?
v:any/c
Added in version 6.0.1.12 of package base.
procedure
The first argument, blame? object encapsulates information about the contract checking, mostly used to create a meaningful error message if a contract violation is detected. The resulting function’s first argument is the value that should have the contract and its second argument is a missing party for the blame object, to be passed to raise-contract-error .
If possible, use this function instead of contract-val-first-projection or contract-projection .
If possible, use contract-late-neg-projection instead.
If possible, use contract-late-neg-projection instead.
procedure
( make-none/c sexp-name)→contract?
sexp-name:any/c
syntax
( recursive-contract contract-exprrecursive-contract-option...)
recursive-contract-option = #:list-contract?| #:extra-delaytype = #:impersonator| #:chaperone| #:flat
If the recursive-contract-option #:list-contract? is given, then the result is a list-contract? and the contract-expr must evaluate to a list-contract? .
If the recursive-contract-option #:extra-delay is given, then the contract-expr expression is evaluated only when the first value to be checked against the contract is supplied to the contract. Without it, the contract-expr is evaluated earlier. This option is supported only when type is #:flat.
> (even-length-list/c'(AB))#t
> (even-length-list/c'(123))#f
Changed in version 6.0.1.13 of package base: Added the #:list-contract? option.
Changed in version 6.7.0.3: Added the #:extra-delay option.
syntax
( opt/c contract-exprmaybe-name)
maybe-name =| #:error-nameid
If the #:error-name argument is present, and contract-expr evaluates to a non-contract expression, then opt/c raises an error using id as the name of the primitive, instead of using the name opt/c .
opt/c: contract violation
expected: contract?
given: '(not-a-contract)
define/contract: contract violation
expected: contract?
given: '(not-a-contract)
syntax
( define-opt/c (idid...)expr)
For example,
[left(val)(bst-between/cloval)][right(val)(bst-between/cvalhi)])))
defines the bst/c contract that checks the binary search tree invariant. Removing the -opt/c also makes a binary search tree contract, but one that is (approximately) 20 times slower.
Note that in some cases, a call to a function defined by define-opt/c may terminate, even if the corresponding define -based function would not terminate. This is a shortcoming in define-opt/c that we hope to understand and fix at some point, but have no concrete plans currently.
Added in version 6.4.0.4 of package base.
procedure
p
Added in version 6.1.1.5 of package base.
procedure
( rename-contract contractname)→contract?
contract:contract?name:any/c
The resulting contract is a flat contract if contract is a flat contract.
Added in version 6.3 of package base.
This will only return #t in the dynamic extent of or/c or first-or/c ’s checking to determine which branch to use.
Added in version 6.3.0.9 of package base.
If not in the dynamic-extent of or/c ’s or first-or/c ’s checking to determine the branch, then this form has no effect.
Added in version 6.3.0.9 of package base.
(if/c procedure? (-> any )any/c )
Added in version 6.3 of package base.
value
Equivalent to (if/c procedure? (-> any )any/c ).
Added in version 6.3 of package base.
See make-contract for more details.
Added in version 6.1.1.5 of package base.
If c does not have a late-neg contract, then this function uses the original projection for it and logs a warning to the 'racket/contract logger.
See make-contract for more details.
Added in version 6.2.900.11 of package base.