((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/typeclass" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg")) (section 2 "typeclass" (toc) (section 3 "Description" (p "Macros for programming in type-class-style in Scheme.")) (section 3 "Author" (p "Andre Van Tonder. Ported to Chicken by " (int-link "users/ivan raikov" "Ivan Raikov") ".")) (section 3 "Requirements" (ul (li (int-link "matchable")))) (section 3 "Documentation" (def (sig (syntax "(define-class NAME FIELD-FORM ...)" (id define-class))) (p "Defines a type class named " (tt "NAME") ", where " (tt "FIELD-FORM ...") " defines one or more fields for instances of this class. " (tt "FIELD-FORM") " should be of the form:") (pre " FIELD-FORM = FIELD-LABEL | (SUPERCLASS-NAME FIELD-LABEL)") (p (tt "SUPERCLASS-NAME") " is the name of a class from which the field is inherited.") (p "The result of this macro is the creation of a constructor with name of the form " (tt "MAKE-CLASSNAME") ", which in turn takes an instance constructor procedure and applies to the given field values.")) (def (sig (syntax "(define=> (<PROCEDURE-NAME> <CLASS-FORM> ...) . BODY)" (id define=>))) (p "Defines a procedure such that all fields of the given class(es) are visible in the scope of the procedure body.") (p (tt "CLASS-FORM") " is of the following form:") (pre "CLASS-FORM = CLASS-NAME | (CLASS-NAME PREFIX-SYMBOL)")) (def (sig (syntax "(lambda=> (<CLASS-FORM> ...) . BODY)" (id lambda=>))) (p "Anonymous procedure such that all fields in the superclasses of the given class are visible in the scope of the procedure body.")) (def (sig (syntax "(with-instance (<INSTANCE-FORM> ...) . BODY)" (id with-instance))) (p "An expression such that all fields of the given class(es) are visible in the scope of " (tt "BODY") ".") (p (tt "INSTANCE-FORM") " is of the following form:") (pre " INSTANCE-FORM = (CLASS-NAME INSTANCE-EXPR)\n                | (CLASS-NAME INSTANCE-EXPR PREFIX-SYMBOL)")) (def (sig (syntax "(import-instance <INSTANCE-FORM> ...)" (id import-instance))) (p "Imports all fields of the given classes as identifiers in the current scope.")) (section 4 "Example" (highlight scheme ";=======================================================\n; Equality example:\n\n; class (Eq a) where\n;   egal?     : a a -> boolean\n;   not-egal? : a a -> boolean\n\n(define-class <Eq> egal?\n                   not-egal?)\n\n(define (default-Eq egal?)\n  (make-<Eq> egal?\n             (lambda (x y) (not (egal? x y)))))\n\n(define num-Eq (default-Eq =))\n(define eqv-Eq (default-Eq eqv?))\n(define chr-Eq (default-Eq char=?))\n"))) (section 3 "Changelog" (ul (li "1.0 Initial Release"))) (section 3 "License" (pre "Copyright (c) 2004-2010, Andre van Tonder, Ivan Raikov.") (pre "Permission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use, copy,\nmodify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE."))))