clalgebraicdatatype
A library for algebraic data types.
CLALGEBRAICDATATYPE
A package for defining algebraic data types.

Struct
ALGEBRAICDATATYPE
Abstract type for all algebraic data types, primarily used to identify such types.No slots. 
Function
ALGEBRAICDATATYPEP
(type)Is TYPE a known algebraic data type? 
Function
ALGEBRAICDATAVALUEP
(value)Is the value VALUE that of some algebraic data type? 
Function
GETCONSTRUCTORS
(adt)Get the constructors and their arity for the adt ADT. Two values will be returned: 1. If the ADT exists, then a list of pairs (CONSTRUCTORSYMBOL ARITY). If the ARITY is zero, then the CONSTRUCTORSYMBOL is a value as opposed to a function. 2. T if the ADT exists, NIL otherwise. This mimics the behavior of GETHASH. 
Variable
*PRINTADTREADABLY*
t
Print preceding #. when printing ADT values. 
Macro
DEFDATA
(adtname &body constructors)Define a new ADT. ADTname has the following grammar: ADTNAME := <symbol>  (<symbol> <options>*) There is no difference between specifying it as a symbol or as a singleton list. There are two possible options, specified as a property list: * :MUTABLE {T, NIL} (default: NIL): Specifies whether the fields of the type are mutable, allowing the use of SETDATA. * :INCLUDE <adttype>: Specifies whether another defined ADT should be inherited. Constructors is a list of clauses with the following grammar: <clause> := <symbol>  (<symbol> <typespecifier>*) Each clause defines a constructor for the ADT. Nullary constructors will define constants and all other constructors will define functions. 
Macro
SETDATA
(obj (name &rest newvalues))Mutate the fields of the ADT value OBJ whose constructor is NAME and whose updated values are NEWVALUES based on order. If the symbol '_' is used as a value, that field is not updated. Trailing '_' may be omitted. 
Macro
WITHDATA
((name &rest vars) obj &body body)Destructure the ADT value OBJ, whose constructor is NAME. VARS must be symbol which will be bound, or they must be the symbol '_', which means the value will not be bound. 
Macro
MATCH
(adt obj &body clauses)Perform pattern matching on OBJ with (adttype) ADT. Each clause must have the following syntax: <var> := <symbol>  '_' <lhs> := '_'  (<symbol> <var>*) <clause> := (<lhs> <lisp code>) The symbol '_' denotes a wildcard, as well as a fallthough. Note that pattern matching is only shallow (patterns are onelevel deep).