Contract-Utils: Various contract functions and utilities
Version 4.0, December 2010
Richard Cobbe <cobbe at ccs dot neu dot edu>
(require (planet cobbe/contract-utils:4/contract-utils)) |
This module provides several general-purpose contracts and contract utilities.
1 Flat Contracts
the empty list
a number
a symbol
a string
a Boolean
a character
a cons cell containing two S-expressions
(nelistof/c c) → contract? |
c : flat-contract/c |
(listof-unique/c elt=?) → flat-contract? |
elt=? : (any/c any/c . -> . boolean?) |
(listof-unique-compare/c cmp) → contract? |
cmp : comparison/c |
2 Higher-Order Contracts
(binary-predicate/c arg/c) → contract? |
arg/c : contract? |
(equality/c arg/c) → contract? |
arg/c : contract? |
(comparison/c arg/c) → contract? |
arg/c : contract? |
(optional/c c) → contract? |
c : contract? |
3 Contract Utilities
(contract-of contract-or-predicate) → contract? |
contract-or-predicate : contract/c |
(predicate-of flat-contract-or-predicate) → predicate/c |
flat-contract-or-predicate : flat-contract/c |
(eta function) |
4 Acknowledgments
Thanks to Carl Eastlund for contract/c, flat-contract/c, contract-of, predicate-of, listof-unique/c, listof-unique-compare/c, equality/c, comparison/c.
5 Copyright and License
This work is copyrighted and distributed under the terms of the Modified BSD License, included below.
Copyright (c) 2005-2010, Richard Cobbe.
All rights reserved.
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
The name of Richard Cobbe may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICHARD COBBE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.