CrossClj

1.2.0 docs

SourceDocs



RECENT
    VARS
    constr-tests-and-bindings
    constructor-code
    constructor-form
    deconstruct
    defadt
    deftype
    deftype-
    list-tests-and-bindings
    map-tests-and-bindings
    match
    qualified-keyword
    qualified-symbol
    resolve-symbol
    sequential-tests-and-bindings
    symbol-tests-and-bindings
    tests-and-bindings
    unqualified-symbol
    vector-tests-and-bindings

    « Index of all namespaces of this project

    General and algebraic data types
    

    — Konrad Hinsen

    Private
    (constr-tests-and-bindings template cfsymbol)
    Private
    (constructor-code meta-map-symbol constructor)
    macro
    (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.
    macro
    (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.
    macro
    (deftype- type-tag constructor-name & optional)
    Same as deftype but the constructor is private.
    
    Private
    (list-tests-and-bindings template vsymbol)
    Private
    (map-tests-and-bindings template vsymbol)
    macro
    (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.
    Private
    (qualified-keyword s)
    Private
    (qualified-symbol s)
    Private
    (resolve-symbol s)
    Private
    (sequential-tests-and-bindings template vsymbol)
    Private
    (symbol-tests-and-bindings template vsymbol)
    Private
    (tests-and-bindings template vsymbol cfsymbol)
    Private
    (unqualified-symbol s)
    Private
    (vector-tests-and-bindings template vsymbol)