PROMOTE layer: lift authored regal syntax into a validated Construct, project it back, and say what a Construct requires of its target.
Everything here is pure and total — a malformed form yields a Result describing why, never an exception and never a silent repair.
(normalize [:cat "a" [:alt "b" "c"]]) => {:ok {…}} (->regal normalized) => [:cat "a" [:alt "b" "c"]] (required-capabilities normalized) => #{}
required-capabilities is what makes dialect support a set-difference
decidable BEFORE emission rather than a try/catch around a compile.
PROMOTE layer: lift authored regal syntax into a validated Construct, project
it back, and say what a Construct requires of its target.
Everything here is pure and total — a malformed form yields a Result
describing why, never an exception and never a silent repair.
(normalize [:cat "a" [:alt "b" "c"]]) => {:ok {…}}
(->regal normalized) => [:cat "a" [:alt "b" "c"]]
(required-capabilities normalized) => #{}
`required-capabilities` is what makes dialect support a set-difference
decidable BEFORE emission rather than a `try`/`catch` around a compile.(->regal {:construct/keys [op text token args entries negated? arg min max
lazy?]})The regal form for CONSTRUCT. Inverse of normalize up to the authored
form's redundancy ([:not …] normalizes into a negated :class and comes
back as [:not …]; [:repeat x 3 3] comes back as [:repeat x 3]).
An ABSENT :construct/max is unbounded, and must be projected as an
explicit nil upper bound: regal reads [:repeat x 3] as {3}, so dropping
the bound would emit an exact repeat for an unbounded construct.
The regal form for CONSTRUCT. Inverse of `normalize` up to the authored
form's redundancy (`[:not …]` normalizes into a negated `:class` and comes
back as `[:not …]`; `[:repeat x 3 3]` comes back as `[:repeat x 3]`).
An ABSENT `:construct/max` is unbounded, and must be projected as an
explicit nil upper bound: regal reads `[:repeat x 3]` as `{3}`, so dropping
the bound would emit an exact repeat for an unbounded construct.(normalize form)Result<Construct> for FORM, which may be regal's authored syntax or an already-normalized Construct.
Total: every rejection names its reason (:construct/unknown-op,
:construct/empty-args, :construct/reversed-range, …) instead of throwing
or guessing.
Result<Construct> for FORM, which may be regal's authored syntax or an already-normalized Construct. Total: every rejection names its reason (`:construct/unknown-op`, `:construct/empty-args`, `:construct/reversed-range`, …) instead of throwing or guessing.
(required-capabilities {:construct/keys [op token entries lazy?] :as construct})The set of Capabilities CONSTRUCT needs of its target dialect.
A dialect supports it exactly when this set is a subset of the dialect's own — no compile, no exception, decided from the shape alone.
The set of Capabilities CONSTRUCT needs of its target dialect. A dialect supports it exactly when this set is a subset of the dialect's own — no compile, no exception, decided from the shape alone.
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 |