Liking cljdoc? Tell your friends :D

pattern.r3.rewrite

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.
raw docstring

*on-marked-insertion*clj


add-env-args*clj

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.
raw docstring

array-or-hash-mapclj

(array-or-hash-map & items)

cleanup-rule-patternclj

Makes syntax-quoted rule patterns presentable

Makes syntax-quoted rule patterns presentable
raw docstring

do-unquote*clj


eval-splicedclj

(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.
raw docstring

evaluate-structureclj

Evaluate syntax quoted forms

Evaluate syntax quoted forms 
raw docstring

expand-andclj

(expand-and types results)

expand-orclj

(expand-or types results)

expand-patternclj


pure-patternclj


qsub*clj


qsub+clj

Same as qsub* but keeps symbol namespaces

Same as qsub* but keeps symbol namespaces
raw docstring

quocljmacro

(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)))
raw docstring

remove-expressionsclj

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.
raw docstring

remove-matcher-nsclj

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.
raw docstring

remove-symbol-namespacesclj


rmetacljmacro

(rmeta)

Expands to (meta (:rule/datom %env))

Expands to (meta (:rule/datom %env))
raw docstring

rule-srcclj

Makes syntax-quoted rules presentable

Makes syntax-quoted rules presentable
raw docstring

scheme-styleclj


simplify-exprclj


simplify-moreclj


splice*clj


splicedclj

(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?
raw docstring

subcljmacro

(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 (?:<- ...)
raw docstring

sub+cljmacro

(sub+ & etc)

Same as sub. Here for backward compatibility

Same as [[sub]]. Here for backward compatibility
raw docstring

sub-cljmacro

(sub- form)
(sub- f form)

Just like sub but strips all namespaces from symbols.

Just like [[sub]] but strips all namespaces from symbols.
raw docstring

submcljmacro

(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.
raw docstring

subm+cljmacro

(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.
raw docstring

to-syntax-quote*clj


unquote-all*clj


unwrap-listclj


unwrap-quoteclj


with-env-argscljmacro

(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.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close