Liking cljdoc? Tell your friends :D

clara.rules.compiler

This namespace is for internal use and may move in the future. This is the Clara rules compiler, translating raw data structures into compiled versions and functions. Most users should use only the clara.rules namespace.

This namespace is for internal use and may move in the future.
This is the Clara rules compiler, translating raw data structures into compiled versions and functions.
Most users should use only the clara.rules namespace.
raw docstring

*compile-ctx*clj

source

add-production-load-orderclj

(add-production-load-order productions)

Adds ::rule-load-order to metadata of productions. Custom DSL's may need to use this if creating a session in Clojure without calling mk-session below.

Adds ::rule-load-order to metadata of productions. Custom DSL's may need to use this if
creating a session in Clojure without calling mk-session below.
sourceraw docstring

analyze-conditionclj

(analyze-condition condition)

Inputs: [condition :- schema/Condition] Returns: {:bound #{sc/Symbol}, :unbound #{sc/Symbol}, :condition schema/Condition, :is-accumulator sc/Bool}

Inputs: [condition :- schema/Condition]
Returns: {:bound #{sc/Symbol}, :unbound #{sc/Symbol}, :condition schema/Condition, :is-accumulator sc/Bool}
sourceraw docstring

BetaNodeclj

These nodes exist in the beta network.

These nodes exist in the beta network.
sourceraw docstring

build-networkclj

(build-network id-to-node
               beta-roots
               alpha-fns
               productions
               fact-type-fn
               ancestors-fn
               activation-group-sort-fn
               activation-group-fn)

Inputs: [id-to-node :- #:sc{Int sc/Any} beta-roots alpha-fns productions fact-type-fn ancestors-fn activation-group-sort-fn activation-group-fn]

Constructs the network from compiled beta tree and condition functions.

Inputs: [id-to-node :- #:sc{Int sc/Any} beta-roots alpha-fns productions fact-type-fn ancestors-fn activation-group-sort-fn activation-group-fn]

Constructs the network from compiled beta tree and condition functions.
sourceraw docstring

clear-session-cache!clj

(clear-session-cache!)

Clears the cache of reusable Clara sessions, so any subsequent sessions will be re-compiled from the rule definitions. This is intended for use by tooling or specialized needs; most users can simply specify the :cache false option when creating sessions.

Clears the cache of reusable Clara sessions, so any subsequent sessions
will be re-compiled from the rule definitions. This is intended for use
by tooling or specialized needs; most users can simply specify the :cache false
option when creating sessions.
sourceraw docstring

cljs-nsclj

(cljs-ns)

Returns the ClojureScript namespace being compiled during Clojurescript compilation.

Returns the ClojureScript namespace being compiled during Clojurescript compilation.
sourceraw docstring

compile-accumclj

(compile-accum accum env)

Used to create accumulators that take the environment into account.

Used to create accumulators that take the environment into account.
sourceraw docstring

compile-actionclj

(compile-action binding-keys rhs env)

Compile the right-hand-side action of a rule, returning a function to execute it.

Compile the right-hand-side action of a rule, returning a function to execute it.
sourceraw docstring

compile-alpha-nodesclj

(compile-alpha-nodes alpha-nodes)

Inputs: [alpha-nodes :- [schema/AlphaNode]] Returns: [{:type sc/Any, :alpha-fn sc/Any, (sc/optional-key :env) #:sc{Keyword sc/Any}, :children [sc/Num]}]

Inputs: [alpha-nodes :- [schema/AlphaNode]]
Returns: [{:type sc/Any, :alpha-fn sc/Any, (sc/optional-key :env) #:sc{Keyword sc/Any}, :children [sc/Num]}]
sourceraw docstring

compile-conditionclj

(compile-condition type destructured-fact constraints result-binding env)

Returns a function definition that can be used in alpha nodes to test the condition.

Returns a function definition that can be used in alpha nodes to test the condition.
sourceraw docstring

compile-join-filterclj

(compile-join-filter {:keys [type constraints args] :as unification-condition}
                     ancestor-bindings
                     element-bindings
                     env)

Compiles to a predicate function that ensures the given items can be unified. Returns a ready-to-eval function that accepts the following:

  • a token from the parent node
  • the fact
  • a map of bindings from the fact, which was typically computed on the alpha side
  • an environment

The function created here returns truthy if the given fact satisfies the criteria.

Compiles to a predicate function that ensures the given items can be unified. Returns a ready-to-eval
function that accepts the following:

* a token from the parent node
* the fact
* a map of bindings from the fact, which was typically computed on the alpha side
* an environment

The function created here returns truthy if the given fact satisfies the criteria.
sourceraw docstring

compile-testclj

(compile-test tests)
source

compiling-cljs?clj

(compiling-cljs?)

Return true if we are currently generating cljs code. Useful because cljx does not provide a hook for conditional macro expansion.

Return true if we are currently generating cljs code.  Useful because cljx does not
provide a hook for conditional macro expansion.
sourceraw docstring

condition-to-nodeclj

(condition-to-node condition env parent-bindings)

Inputs: [condition :- schema/Condition env :- (sc/maybe #:sc{Keyword sc/Any}) parent-bindings :- #{sc/Keyword}] Returns: schema/ConditionNode

Converts a condition to a node structure.

Inputs: [condition :- schema/Condition env :- (sc/maybe #:sc{Keyword sc/Any}) parent-bindings :- #{sc/Keyword}]
Returns: schema/ConditionNode

Converts a condition to a node structure.
sourceraw docstring

condition-typeclj

(condition-type condition)

Returns the type of a single condition that has been transformed to disjunctive normal form. The types are: :negation, :accumulator, :test, :exists, and :join

Returns the type of a single condition that has been transformed
to disjunctive normal form. The types are: :negation, :accumulator, :test, :exists, and :join
sourceraw docstring

effective-typeclj

(effective-type type)
source

field-name->accessors-usedclj

(field-name->accessors-used type constraints)

Returns a map of field name to accessors for any field names of type used in the constraints.

Returns a map of field name to accessors for any field names of type used
in the constraints.
sourceraw docstring

flatten-expressionclj

(flatten-expression expression)

Flattens expression as clojure.core/flatten does, except will flatten anything that is a collection rather than specifically sequential.

Flattens expression as clojure.core/flatten does, except will flatten
anything that is a collection rather than specifically sequential.
sourceraw docstring

get-fieldsclj

(get-fields type)

Returns a map of field name to a symbol representing the function used to access it.

Returns a map of field name to a symbol representing the function used to access it.
sourceraw docstring

get-namespace-infoclj

(get-namespace-info namespace)

Get metadata about the given namespace.

Get metadata about the given namespace.
sourceraw docstring

IRuleSourcecljprotocol

load-rulesclj

(load-rules source)
source

mk-sessionclj

(mk-session sources-and-options)

Creates a new session using the given rule source. The resulting session is immutable, and can be used with insert, retract, fire-rules, and query functions.

Creates a new session using the given rule source. The resulting session
is immutable, and can be used with insert, retract, fire-rules, and query functions.
sourceraw docstring

mk-session*clj

(mk-session* productions options)

Inputs: [productions :- #{schema/Production} options :- #:sc{Keyword sc/Any}]

Compile the rules into a rete network and return the given session.

Inputs: [productions :- #{schema/Production} options :- #:sc{Keyword sc/Any}]

Compile the rules into a rete network and return the given session.
sourceraw docstring

production-load-order-compclj

(production-load-order-comp a b)
source

resolve-cljs-symclj

(resolve-cljs-sym ns-sym sym)

Resolves a ClojureScript symbol in the given namespace.

Resolves a ClojureScript symbol in the given namespace.
sourceraw docstring

sort-conditionsclj

(sort-conditions conditions)

Inputs: [conditions :- [schema/Condition]] Returns: [schema/Condition]

Performs a topologic sort of conditions to ensure variables needed by child conditions are bound.

Inputs: [conditions :- [schema/Condition]]
Returns: [schema/Condition]

Performs a topologic sort of conditions to ensure variables needed by
 child conditions are bound.
sourceraw docstring

strict-map->Rulebaseclj

(strict-map->Rulebase m6713 & [drop-extra-keys?__1339__auto__])

Factory function for class Rulebase, taking a map of keywords to field values. All keys are required, and no extra keys are allowed. Even faster than map->

Factory function for class Rulebase, taking a map of keywords to field values.  All keys are required, and no extra keys are allowed.  Even faster than map->
sourceraw docstring

to-alpha-graphclj

(to-alpha-graph beta-graph)

Inputs: [beta-graph :- schema/BetaGraph] Returns: [schema/AlphaNode]

Returns a sequence of [condition-fn, [node-ids]] tuples to represent the alpha side of the network.

Inputs: [beta-graph :- schema/BetaGraph]
Returns: [schema/AlphaNode]

Returns a sequence of [condition-fn, [node-ids]] tuples to represent the alpha side of the network.
sourceraw docstring

to-beta-graphclj

(to-beta-graph productions)

Inputs: [productions :- #{schema/Production}] Returns: schema/BetaGraph

Produces a description of the beta network.

Inputs: [productions :- #{schema/Production}]
Returns: schema/BetaGraph

Produces a description of the beta network.
sourceraw docstring

to-dnfclj

(to-dnf expression)

Convert a lhs expression to disjunctive normal form.

Convert a lhs expression to disjunctive normal form.
sourceraw docstring

try-evalclj

(try-eval expr)

Evals the given expr. If an exception is thrown, it is caught and an ex-info exception is thrown with more details added. Uses compile-ctx for additional contextual info to add to the exception details.

Evals the given `expr`.  If an exception is thrown, it is caught and an
ex-info exception is thrown with more details added.  Uses *compile-ctx*
for additional contextual info to add to the exception details.
sourceraw docstring

validate-names-uniqueclj

(validate-names-unique productions)

Checks that all productions included in the session have unique names, throwing an exception if duplicates are found.

Checks that all productions included in the session have unique names,
throwing an exception if duplicates are found.
sourceraw docstring

variables-as-keywordsclj

(variables-as-keywords expression)

Returns a set of the symbols in the given s-expression that start with '?' as keywords

Returns a set of the symbols in the given s-expression that start with '?' as keywords
sourceraw docstring

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

× close