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.
(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.
(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}
These nodes exist in the beta network.
These nodes exist in the beta network.
(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.
(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.
(cljs-ns)
Returns the ClojureScript namespace being compiled during Clojurescript compilation.
Returns the ClojureScript namespace being compiled during Clojurescript compilation.
(compile-accum accum env)
Used to create accumulators that take the environment into account.
Used to create accumulators that take the environment into account.
(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.
(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]}]
(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.
(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:
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.
(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.
(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.
(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
(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.
(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.
(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.
(get-namespace-info namespace)
Get metadata about the given namespace.
Get metadata about the given namespace.
(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.
(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.
(resolve-cljs-sym ns-sym sym)
Resolves a ClojureScript symbol in the given namespace.
Resolves a ClojureScript symbol in the given namespace.
(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.
(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->
(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.
(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.
(to-dnf expression)
Convert a lhs expression to disjunctive normal form.
Convert a lhs expression to disjunctive normal form.
(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.
(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.
(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
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close