The cl-algebraic-data-type Reference Manual

This is the cl-algebraic-data-type Reference Manual, version 1.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 04:36:54 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-algebraic-data-type

A library for algebraic data types.

Author

Robert Smith <>

License

BSD 3-clause

Version

1.2.0

Dependencies
  • alexandria (system).
  • global-vars (system).
Source

cl-algebraic-data-type.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 cl-algebraic-data-type/cl-algebraic-data-type.asd

Source

cl-algebraic-data-type.asd.

Parent Component

cl-algebraic-data-type (system).

ASDF Systems

cl-algebraic-data-type.


3.1.2 cl-algebraic-data-type/package.lisp

Dependency

license.txt (file).

Source

cl-algebraic-data-type.asd.

Parent Component

cl-algebraic-data-type (system).

Packages

cl-algebraic-data-type.


3.1.3 cl-algebraic-data-type/utilities.lisp

Dependency

package.lisp (file).

Source

cl-algebraic-data-type.asd.

Parent Component

cl-algebraic-data-type (system).

Public Interface
Internals

3.1.4 cl-algebraic-data-type/defdata.lisp

Dependency

utilities.lisp (file).

Source

cl-algebraic-data-type.asd.

Parent Component

cl-algebraic-data-type (system).

Public Interface

3.1.5 cl-algebraic-data-type/match.lisp

Dependency

defdata.lisp (file).

Source

cl-algebraic-data-type.asd.

Parent Component

cl-algebraic-data-type (system).

Public Interface

match (macro).

Internals

duplicates (function).


3.1.6 cl-algebraic-data-type/do-notation.lisp

Dependency

match.lisp (file).

Source

cl-algebraic-data-type.asd.

Parent Component

cl-algebraic-data-type (system).

Internals

do-notation (macro).


3.2 Static


3.2.1 cl-algebraic-data-type/LICENSE.txt

Source

cl-algebraic-data-type.asd.

Parent Component

cl-algebraic-data-type (system).


4 Packages

Packages are listed by definition order.


4.1 cl-algebraic-data-type

A package for defining algebraic data types.

Source

package.lisp.

Nickname

adt

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *print-adt-readably*

Print preceding #. when printing ADT values.

Package

cl-algebraic-data-type.

Source

defdata.lisp.


5.1.2 Macros

Macro: defdata (adt-name &body constructors)

Define a new ADT. ADT-name has the following grammar:

ADT-NAME := <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 SET-DATA.

* :INCLUDE <adt-type>: Specifies whether another defined ADT should be inherited.

Constructors is a list of clauses with the following grammar:

<clause> := <symbol>
| (<symbol> <type-specifier>*)

Each clause defines a constructor for the ADT. Nullary constructors will define constants and all other constructors will define functions.

Package

cl-algebraic-data-type.

Source

defdata.lisp.

Macro: match (adt obj &body clauses)

Perform pattern matching on OBJ with (adt-type) 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 one-level deep).

Package

cl-algebraic-data-type.

Source

match.lisp.

Macro: set-data (obj (name &rest new-values))

Mutate the fields of the ADT value OBJ whose constructor is NAME and whose updated values are NEW-VALUES based on order. If the symbol ’_’ is used as a value, that field is not updated. Trailing ’_’ may be omitted.

Package

cl-algebraic-data-type.

Source

defdata.lisp.

Macro: with-data ((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.

Package

cl-algebraic-data-type.

Source

defdata.lisp.


5.1.3 Ordinary functions

Function: algebraic-data-type-p (type)

Is TYPE a known algebraic data type?

Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: algebraic-data-value-p (value)

Is the value VALUE that of some algebraic data type?

Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: get-constructors (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

(CONSTRUCTOR-SYMBOL ARITY).

If the ARITY is zero, then the CONSTRUCTOR-SYMBOL is a value as opposed to a function.

2. T if the ADT exists, NIL otherwise. This mimics the behavior of GETHASH.

Package

cl-algebraic-data-type.

Source

utilities.lisp.


5.1.4 Structures

Structure: algebraic-data-type

Abstract type for all algebraic data types, primarily used to identify such types.

Package

cl-algebraic-data-type.

Source

utilities.lisp.

Direct superclasses

structure-object.


5.2 Internals


5.2.1 Macros

Macro: define-constant (name value documentation)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Macro: do-notation (bind-function expressions &body body)

Given a BIND-FUNCTION and all the bind expressions, evaluate BODY.

Package

cl-algebraic-data-type.

Source

do-notation.lisp.


5.2.2 Ordinary functions

Function: duplicates (sequence &key test)
Package

cl-algebraic-data-type.

Source

match.lisp.

Function: ensure-car (x)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: ensure-list (x)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: field (name n)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: gen-names (n)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: internal (s)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: property-list-p (x &rest keys)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: set-constructors (adt constructors)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: unsplice (x)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: unwrap-singletons (list)
Package

cl-algebraic-data-type.

Source

utilities.lisp.

Function: wild? (s)
Package

cl-algebraic-data-type.

Source

utilities.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   D   E   F   G   I   M   P   S   U   W  
Index Entry  Section

A
algebraic-data-type-p: Public ordinary functions
algebraic-data-value-p: Public ordinary functions

D
defdata: Public macros
define-constant: Private macros
do-notation: Private macros
duplicates: Private ordinary functions

E
ensure-car: Private ordinary functions
ensure-list: Private ordinary functions

F
field: Private ordinary functions
Function, algebraic-data-type-p: Public ordinary functions
Function, algebraic-data-value-p: Public ordinary functions
Function, duplicates: Private ordinary functions
Function, ensure-car: Private ordinary functions
Function, ensure-list: Private ordinary functions
Function, field: Private ordinary functions
Function, gen-names: Private ordinary functions
Function, get-constructors: Public ordinary functions
Function, internal: Private ordinary functions
Function, property-list-p: Private ordinary functions
Function, set-constructors: Private ordinary functions
Function, unsplice: Private ordinary functions
Function, unwrap-singletons: Private ordinary functions
Function, wild?: Private ordinary functions

G
gen-names: Private ordinary functions
get-constructors: Public ordinary functions

I
internal: Private ordinary functions

M
Macro, defdata: Public macros
Macro, define-constant: Private macros
Macro, do-notation: Private macros
Macro, match: Public macros
Macro, set-data: Public macros
Macro, with-data: Public macros
match: Public macros

P
property-list-p: Private ordinary functions

S
set-constructors: Private ordinary functions
set-data: Public macros

U
unsplice: Private ordinary functions
unwrap-singletons: Private ordinary functions

W
wild?: Private ordinary functions
with-data: Public macros


A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*print-adt-readably*: Public special variables

S
Special Variable, *print-adt-readably*: Public special variables


A.4 Data types