intentions.core

Macros and functions for defining intentions.

add-conduct

(add-conduct intent dispatch-val conduct-fn)

Adds a conduct function to an intention for the supplied dispatch value. See: defconduct.

conducts

(conducts intent)

Returns a map of dispatch values to conduct functions for an intention.

defconduct

macro

(defconduct intent dispatch-val & fn-tail)

Creates and adds a new conduct function, associated with dispatch-val, to the supplied intention.

defintent

macro

(defintent name docstring? attr-map? & options)

Create a new intention with the associated options. The docstring and attribute map are optional.

Options are key-value pairs and may be one of:

:dispatch
the dispatch function, required
:combine
the combine function, required
:default
the default dispatch value, defaults to :default
:hierarchy
the isa? hierarchy to use for dispatching, defaults to the global hierarchy

intent?

(intent? x)

Returns true if its argument is an intention.

make-intent

(make-intent & {:keys [dispatch combine default hierarchy], :or {default :default}})

Create an anonymous intention. See: defintent.

prefer-conduct

(prefer-conduct intent dispatch-val-x dispatch-val-y)

Causes an intention to evaluate conducts for dispatch-val-x after dispatch-val-y, when neither dispatch value is more specific.

remove-conduct

(remove-conduct intent dispatch-val)

Removes a conduct function from an intention for the supplied dispatch value.