8.16.0.1
3.11 Typeclass
(require cur/stdlib/typeclass) | package: cur-lib |
This library defines some macros that provide ad-hoc polymorphism
similar to typeclasses, although lacking some of the crucial features
of typeclasses such as typeclass constraints. These typeclasses are
added entirely through meta-programming.
syntax
(typeclass (class (param : Type)) (name : t) ...)
Declares a new typeclass named class, whose parameter
param has type Type. Implementations of this
typeclass must define of the methods name ... whose types
are t ....
Example:
syntax
(impl (class param) defs ...)
Provides an implementation of the typeclass class for the
type param. The defintions defs ... are Cur
definitions for each of the methods of the typeclass.
Examples: