doc.txt

Contract-utils

_Contract-utils_
_contract-utils_

Version 2.1
Richard Cobbe
<cobbe at ccs dot neu dot edu>

This collection provides one file, _contract-utils.ss_, which implements
several general-purpose contracts and contract utilities.

Version 2 of this library requires MzScheme version 301.7 or later.  If you
need to run this library with an earlier version of MzScheme, please use
version 1.  (I will keep version 1 updated with bug fixes, but I do not
currently intend to add new functionality to the older version.)

ACKNOWLEDGMENTS: Thanks to Carl Eastlund for contract/c, flat-contract/c,
contract-of, and predicate-of.

======================================================================

> (nelistof/c flat-contract) 

This function accepts a flat contract (or a predicate, which is converted
to a flat contract) and produces a contract that recognizes non-empty lists
whose elements match the given contract.

> sexp/c

This flat contract recognizes arbitrary S-expressions.  Here, an
S-expression is either the empty list, a number, a symbol, a string, a
Boolean, a character, or a cons cell containing two S-expressions.

> predicate/c

This contract recognizes (unary) predicate functions.  A predicate function
is a function which can consume any single value and always produces a
Boolean result.

> (optional/c contract)

This function accepts a contract (or a predicate) and produces a contract
that recognizes an optional value---that is, either a value that satisfies
the given contract, or #f.  The resulting contract is flat if and only if
the argument is a flat contract or predicate.

> positive-int/c

This flat contract recognizes strictly positive integers.

> contract/c

This contract recognizes contracts and predicates.

> flat-contract/c

This contract recognizes flat contracts and predicates.

> (contract-of contract-or-predicate)

This function wraps a predicate in a flat-contract and leaves contracts
unchanged.

> (predicate-of flat-contract-or-predicate)

This function extracts a flat contract's predicate and leaves predicates
unchanged.

> (eta function)

This macro simply eta-expands function; that is, it expands to 
    (lambda args (apply function args)) .
This is useful primarily to allow contract specifications to appear before
their predicate definitions, for legibility reasons.

======================================================================

Contract-Utils: general-purpose PLT contract utilities.
Copyright (C) 2005  Richard Cobbe

This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Clarification: I consider that simply using this library as a client, by
specifying its PLaneT module path in a require clause, is "mere
aggregation" according to the terms of the GNU LGPL, and therefore this
usage does not constrain the terms of the license under which you release
your client program.