This namespace defines several rulesets and related macros that enhance the expressive power of the rules engine.
Most of these rulesets are defined in a style inspired by the nanopass compiler, using directed to control the rule matcher's descent into the expression being transformed.
The rules defined in this namespace must make use of a limited subset of this library's functionality since they are defining that functionality in terms of the base operations.
Arity-1 rules may not be used, nor may sub or quo.
This namespace defines several functions in terms of various combinations of the same rulesets. The core idea is to transform native Clojure sytax-quoted forms. In the case of regular quoted lists, they may be expanded into syntax-quoted form before being transformed and then possibly simplified back as close to their original shape as possible. This transformation enables unquoting on regular quoted lists and other data structures.
Note that sequence
is included in the rules because when booting, Clojure's
syntax quote expands slightly differently than at runtime. It also uses lists rather
than Cons objects at boot.
This namespace defines several rulesets and related macros that enhance the expressive power of the rules engine. Most of these rulesets are defined in a style inspired by the nanopass compiler, using directed to control the rule matcher's descent into the expression being transformed. The rules defined in this namespace must make use of a limited subset of this library's functionality since they are defining that functionality in terms of the base operations. Arity-1 rules may not be used, nor may sub or quo. This namespace defines several functions in terms of various combinations of the same rulesets. The core idea is to transform native Clojure sytax-quoted forms. In the case of regular quoted lists, they may be expanded into syntax-quoted form before being transformed and then possibly simplified back as close to their original shape as possible. This transformation enables unquoting on regular quoted lists and other data structures. Note that `sequence` is included in the rules because when booting, Clojure's syntax quote expands slightly differently than at runtime. It also uses lists rather than Cons objects at boot.
The rewrite used by a macro that recursively adds metadata to rules before the rule macro runs. It uses the metadata to let-bind values from %env within rule-handlers.
The rewrite used by a macro that recursively adds metadata to rules before the rule macro runs. It uses the metadata to let-bind values from %env within rule-handlers.
(array-or-hash-map & items)
Makes syntax-quoted rule patterns presentable
Makes syntax-quoted rule patterns presentable
(eval-spliced x)
Experimental. Uses spliced
to transform regular lists, then uses eval to
resolve spliced data. Doesn't resolve any data in the local scope.
Experimental. Uses [[spliced]] to transform regular lists, then uses eval to resolve spliced data. Doesn't resolve any data in the local scope.
(expand-and types results)
(expand-or types results)
Same as qsub* but keeps symbol namespaces
Same as qsub* but keeps symbol namespaces
(quo expr)
Remove symbol namespaces.
Useful for cleaning up namespaces in syntax-quoted input data. Otherwise, use
sub
.
Requires that the expression is syntax quoted. Does not perform any other transformation.
Usage:
(quo `(expt x ~(+ 1 1)))
Remove symbol namespaces. Useful for cleaning up namespaces in syntax-quoted input data. Otherwise, use [[sub]]. Requires that the expression is syntax quoted. Does not perform any other transformation. Usage: (quo `(expt x ~(+ 1 1)))
Replace all unquoted expressions with 'identity but leave the structure of the expression unmodified.
Replace all unquoted expressions with 'identity but leave the structure of the expression unmodified.
This makes (some.ns/? some.ns/x) look like (? x), etc when displaying rules.
This makes (some.ns/? some.ns/x) look like (? x), etc when displaying rules.
(rmeta)
Expands to (meta (:rule/datom %env))
Expands to (meta (:rule/datom %env))
Makes syntax-quoted rules presentable
Makes syntax-quoted rules presentable
(spliced form)
A function that allows regular quoted lists to be spliced just like
syntax-quoted ones, but only really works within macros because the spliced in
data needs to be evaluated and it doesn't seem possible to do that at runtime
except with [[eval]], which does not use the current evaluation scope. If that
works for you, use eval-spliced
, but usually you will be better off with
either the sub
(recommended), or quo
macros.
This may eventually be useful together with SCI?
A function that allows regular quoted lists to be spliced just like syntax-quoted ones, but only really works within macros because the spliced in data needs to be evaluated and it doesn't seem possible to do that at runtime except with [[eval]], which does not use the current evaluation scope. If that works for you, use [[eval-spliced]], but usually you will be better off with either the [[sub]] (recommended), or [[quo]] macros. This may eventually be useful together with SCI?
(sub form)
(sub f form)
Statically macroexpand substitution patterns expressed exactly like matcher patterns.
This produces what I expect shoud be optimally fast substitutions, but differs
from pattern.substitute/substitute
in that it requires that all substitution patterns
must be bound, and will produce a compilation error if not.
The arity 2 version allows substitutions to be transformed by the supplied function before being inserted if they are marked with <- or wrapped with (?:<- ...)
Statically macroexpand substitution patterns expressed exactly like matcher patterns. This produces what I expect shoud be optimally fast substitutions, but differs from [[pattern.substitute/substitute]] in that it requires that all substitution patterns must be bound, and will produce a compilation error if not. The arity 2 version allows substitutions to be transformed by the supplied function before being inserted if they are marked with <- or wrapped with (?:<- ...)
(sub+ & etc)
Same as sub
. Here for backward compatibility
Same as [[sub]]. Here for backward compatibility
(sub- form)
(sub- f form)
Just like sub
but strips all namespaces from symbols.
Just like [[sub]] but strips all namespaces from symbols.
(subm form)
(subm form metadata)
Perform substitution and attach the provided metadata.
If called arity-1, copy the rule's original matching form's metadata onto the resulting form, using rmeta to capture the metadata.
Perform substitution and attach the provided metadata. If called arity-1, copy the rule's original matching form's metadata onto the resulting form, using rmeta to capture the metadata.
(subm+ form)
(subm+ form metadata)
Like subm
but checks that form is an IObj before attaching metadata.
Useful for generated expressions.
Like [[subm]] but checks that form is an IObj before attaching metadata. Useful for generated expressions.
(with-env-args bindings rules)
Attach :env-args metadata to rules to enable convenient binding of env data in the rule handlers.
Attach :env-args metadata to rules to enable convenient binding of env data in the rule handlers.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close