You are looking at historical revision 18669 of this page. It may differ significantly from its current revision.

typeclass

Description

Macros for programming in type-class-style in Scheme.

Author

Andre Van Tonder

Requirements

Documentation

[syntax] (define-class NAME FIELD-FORM ...)

Defines a type class named NAME, where FIELD-FORM ... defines one or more fields for instances of this class. FIELD-FORM should be of the form:

 FIELD-FORM = FIELD-LABEL | (SUPERCLASS-NAME FIELD-LABEL)

SUPERCLASS-NAME is the name of a class from which the field is inherited.

The result of this macro is the creation of a constructor with name of the form MAKE-CLASSNAME, which in turn takes an instance constructor procedure and applies to the given field values.

[syntax] (define=> (<PROCEDURE-NAME> <CLASS-FORM> ...) . BODY)

Defines a procedure such that all fields in the superclasses of the given class(es) are visible in the scope of the procedure body.

CLASS-FORM is of the following form:

CLASS-FORM = CLASS-NAME | (CLASS-NAME PREFIX-SYMBOL)
[syntax] (lambda=> (<CLASS-FORM> ...) . BODY)

Anonymous procedure such that all fields in the superclasses of the given class are visible in the scope of the procedure body.

Example

Examples:

=>

Changelog

License

Copyright (c) 2004-2010, Andre van Tonder, Ivan Raikov.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.