API for types
- ()
by Konrad Hinsen
clojure-contrib is now deprecated
clojure-contrib is no longer being developed or maintained.
Rather than a single, monolithic, contributions library, Clojure now has
a set of separate libraries for each unit of functionality. The libraries
are in the Clojure GitHub organization at
https://github.com/clojure.
API documentation of the libraries can be found at
https://clojure.github.io.
If you're looking for a specific function or namespace from the old
clojure-contrib, see
"Where Did Clojure.Contrib Go".
Full namespace name:
clojure.contrib.types
Overview
General and algebraic data types
Public Variables and Functions
defadt
macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (defadt type-tag & constructors)
Define an algebraic data type name by an exhaustive list of constructors.
Each constructor can be a symbol (argument-free constructor) or a
list consisting of a tag symbol followed by the argument symbols.
The data type tag must be a keyword.
Source
deftype
macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (deftype type-tag constructor-name docstring? attr-map?)
(deftype type-tag constructor-name docstring? attr-map? constructor)
(deftype type-tag constructor-name docstring? attr-map? constructor deconstructor)
Define a data type by a type tag (a namespace-qualified keyword)
and a symbol naming the constructor function. Optionally, a
constructor and a deconstructor function can be given as well,
the defaults being clojure.core/identity and clojure.core/list.
The full constructor associated with constructor-name calls the
constructor function and attaches the type tag to its result
as metadata. The deconstructor function must return the arguments
to be passed to the constructor in order to create an equivalent
object. It is used for printing and matching.
Source
deftype-
macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (deftype- type-tag constructor-name & optional)
Same as deftype but the constructor is private.
Source
match
macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (match value & clauses)
Given a value and a list of template-expr clauses, evaluate the first
expr whose template matches the value. There are four kinds of templates:
1) Lists of the form (tag x1 x2 ...) match instances of types
whose constructor has the same form as the list.
2) Quoted lists of the form '(x1 x2 ...) match lists of the same
length.
3) Vectors of the form [x1 x2 ...] match vectors of the same length.
4) Maps of the form {:key1 x1 :key2 x2 ...} match maps that have
the same keys as the template, but which can have additional keys
that are not part of the template.
The values x1, x2, ... can be symbols or non-symbol values. Non-symbols
must be equal to the corresponding values in the object to be matched.
Symbols will be bound to the corresponding value in the object in the
evaluation of expr. If the same symbol occurs more than once in a,
template the corresponding elements of the object must be equal
for the template to match.
Source