Deterministic planner. Pure: a profile and a registry in, a Result out.
Search is best-first by structural cost: a candidate's cost is the sum of its realization and wrapper costs, literal encoders adding 0, so a direct realization can lose to a cheaper delegation. Equal costs break by pre-order (direct before delegation, realizations by [cost id], children left to right). The first candidate whose text satisfies the profile's text constraints wins.
A realization is admitted only when every capability it requires is :yes. An :unknown never selects a program. When nothing is admitted the search runs again with unknowns let through, only to report what resolving them would unlock (:blocked-on-unknown).
Deterministic planner. Pure: a profile and a registry in, a Result out. Search is best-first by structural cost: a candidate's cost is the sum of its realization and wrapper costs, literal encoders adding 0, so a direct realization can lose to a cheaper delegation. Equal costs break by pre-order (direct before delegation, realizations by [cost id], children left to right). The first candidate whose text satisfies the profile's text constraints wins. A realization is admitted only when every capability it requires is :yes. An :unknown never selects a program. When nothing is admitted the search runs again with unknowns let through, only to report what resolving them would unlock (:blocked-on-unknown).
(candidates env visited lang intent)Lazy, deterministic seq of candidates for intent in lang, cheapest total cost first; ties go to a direct realization, then by cost and id. visited holds the languages already on the context stack, so delegation never cycles. Candidates longer than the profile's :max-len are dropped at every level (see within-len).
Lazy, deterministic seq of candidates for intent in lang, cheapest total cost first; ties go to a direct realization, then by cost and id. visited holds the languages already on the context stack, so delegation never cycles. Candidates longer than the profile's :max-len are dropped at every level (see within-len).
(explain env langs [op :as intent] pairs)Every option the planner had for intent, with its required capabilities split by verdict. pairs restricts wrappers to those [outer inner] pairs; nil means every cross-language wrapper between langs.
Every option the planner had for intent, with its required capabilities split by verdict. pairs restricts wrappers to those [outer inner] pairs; nil means every cross-language wrapper between langs.
(make-env profile {:keys [realizations wrappers admit] :or {admit p/admits?}})Planning environment over profile. admit is (fn [profile requires] bool), default grammar.profile/admits? (all :yes).
Refuses, as ex-info, a realization or wrapper whose :id is not a keyword (ids rank equal costs, and mixed id types do not compare) or whose :cost is not a number >= 0 (a cost is a lower bound for everything under it, which a negative cost would break).
Planning environment over profile. admit is (fn [profile requires] bool), default grammar.profile/admits? (all :yes). Refuses, as ex-info, a realization or wrapper whose :id is not a keyword (ids rank equal costs, and mixed id types do not compare) or whose :cost is not a number >= 0 (a cost is a lower bound for everything under it, which a negative cost would break).
(requires-of r intent)Capabilities realization r relies on for intent: its static :requires plus whatever its optional :requires-of (fn [intent] caps) adds.
Capabilities realization r relies on for intent: its static :requires plus whatever its optional :requires-of (fn [intent] caps) adds.
(solve env lang intent)(solve env lang intent {:keys [stack budget] :or {budget 5000}})Plan intent in lang under env. opts: :stack (force a context stack, outermost first; overrides lang), :budget (max candidates per search pass, examined plus pruned, default 5000). Always returns a grammar.schema/Result.
:searched, :rejected, :pruned and :pruned-min-bytes are diagnostics, not contract: how many candidates the strict pass examined, the first ones it rejected, how many both passes dropped unexamined because their code already exceeded :max-len, and the shortest of those. A pass that reaches its budget stops and the Result says :budget-exhausted. Pruning changes the diagnostics, never the chosen program, as long as no pass reaches its budget: past it, a pruned search may stop at a different point than an unpruned one would.
Plan intent in lang under env. opts: :stack (force a context stack, outermost first; overrides lang), :budget (max candidates per search pass, examined plus pruned, default 5000). Always returns a grammar.schema/Result. :searched, :rejected, :pruned and :pruned-min-bytes are diagnostics, not contract: how many candidates the strict pass examined, the first ones it rejected, how many both passes dropped unexamined because their code already exceeded :max-len, and the shortest of those. A pass that reaches its budget stops and the Result says :budget-exhausted. Pruning changes the diagnostics, never the chosen program, as long as no pass reaches its budget: past it, a pruned search may stop at a different point than an unpruned one would.
Length of a string in UTF-8 bytes (grammar.law/utf8-len).
Length of a string in UTF-8 bytes (grammar.law/utf8-len).
(violations {:keys [max-len forbid]} code)Text constraints a program breaks. Empty vector when it satisfies them.
Text constraints a program breaks. Empty vector when it satisfies them.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |