@lionlang/core/schemas/lion-expression
The core expression schemas describe the full range of values a Lion program can contain.
The top-level union schema. Accepts any value that is a JSON primitive, an
array of Lion expressions, or a record with string keys and Lion expression
values. This is the schema used by
run to validate the expression
parameter before evaluation.A
Schema.Array of recursively-suspended LionExpressionSchema elements.
Used by evaluate to detect array expressions and dispatch them to
evaluateArray.A
Schema.Record where:- Keys must be non-empty strings (
minLength(1)) and must not equal"__proto__". - Values are recursively-suspended
LionExpressionSchemaelements.
evaluate to detect record expressions and dispatch them to
evaluateRecord.A recursive TypeScript type alias representing the structural form of a Lion
expression before schema decoding:Used as the element type for the lazy
Schema.suspend references inside the
array and record schemas.Runtime type checking
UseSchema.is to narrow a value to a specific expression shape at runtime without throwing on failure:
@lionlang/core/schemas/json-primitive
A union of
Schema.String, Schema.Number, Schema.Boolean, and
Schema.Null. Represents the leaf values of a Lion expression tree.
Numbers, booleans, and null evaluate to themselves; strings are resolved
as environment references.@lionlang/core/schemas/environment
The union type of
ToplevelEnvironment and InnerEnvironment. Both carry a
bindingsRef: Ref<Record<string, unknown>> for mutable name storage.
InnerEnvironment additionally holds a parent: Environment reference for
lexical scope lookup.You do not typically construct Environment values directly — use
makeEnvironment from @lionlang/core/evaluation/environment instead.@lionlang/core/schemas/evaluation
Special form schemas and the callable value schema. Import what you need:
["eval", LionExpression] — evaluates its argument, then evaluates the result.["quote", LionExpression] — returns its argument unevaluated.["begin", ...LionExpression[]] — evaluates a sequence of expressions and returns the last value.["define", ValidIdentifier, LionExpression] — evaluates the expression and stores it in the global environment under ValidIdentifier. The identifier must be non-empty and cannot be one of the reserved keywords (begin, define, eval, quote, lambda, cond, match) or __proto__.["lambda", ValidIdentifier[], LionExpression] — creates a closure over the current scope.Union of The
CondFormWithoutElseSchema and CondFormWithElseSchema:else branch is optional. Returns null when no branch matches and no else is present.[LionExpression, ...LionExpression[]] — a non-empty tuple where the head evaluates to a callable. Used as the final catch-all in evaluateArray after all special forms have been checked.A declared schema that matches any JavaScript
function. Used to validate that the head of a function call expression is actually callable: