@inhuman.tools/arrival-overridable-lens
v0.9.9
Published
Static (pre-eval) substrate for reading a program's `(define/overridable …)` surface: the canonical top-level parse-tree walk plus `foldSchemaTag`, the pre-eval dual of core's post-eval `tagToJsonSchema`. Consumed one-way by the out-of-core overridable le
Maintainers
Readme
@inhuman.tools/arrival-overridable-lens
Static, pre-eval read of Arrival Scheme knobs ((define/overridable …)). Parses a source string; does not evaluate.
Install
pnpm add @inhuman.tools/arrival-overridable-lensRequires @inhuman.tools/arrival.
Usage
import { extractOverridableForms, foldSchemaTag } from "@inhuman.tools/arrival-overridable-lens";
const source = `(define/overridable tagline (s/string) "Build faster")`;
const forms = await extractOverridableForms(source); // top-level knobs; [] on parse failure
for (const f of forms) {
const tag = foldSchemaTag(f.typeNode); // { ok: true, value: "string" }
// f.defaultNode is the raw default parse node — evaluate or read it per your need
}The surface, in two halves:
- Walk —
overridableFormsFromForms(over already-parsed forms; pure, never throws) andextractOverridableForms(parses a source,[]on failure). Top-level only; hands back rawtypeNode/defaultNodeparse nodes. PlusextractRequiresfor the config-in-config(require …)edges. - Fold —
foldSchemaTag: a parse node of ans/*schema form → its canonical tagged-list value, with zero evaluation. The pre-eval dual of core's post-evaltagToJsonSchema(@inhuman.tools/arrival/schema-tag).
Used by hosts (form fields, an API :input deriver, CLI argv mapping).
License
MIT.
