run is the primary entry point for executing Lion programs. It accepts any JSON-compatible value as the expression and a plain object as the evaluation environment, then takes care of schema decoding, evaluation dispatch, and Effect context provisioning so callers do not need to interact with the internals directly.
Signature
Parameters
The Lion expression to evaluate. Accepts any JSON-compatible value — a JSON
primitive (
string, number, boolean, null), an array of Lion
expressions, or a record with string keys and Lion expression values. The
value is decoded against LionExpressionSchema before evaluation begins.Name bindings available during evaluation. Keys are identifier strings;
values can be primitives, objects, or JavaScript functions. Pass the
stdlib export from @lionlang/core/modules to make the standard library
available, then spread in any additional host bindings.Return value
An Effect that, when run, yields the evaluated result or fails with one of three typed errors:
Pipeline
Internally,run composes three steps:
- Schema decoding —
Schema.decodeUnknown(LionExpressionSchema)validates and narrowsexpressiontoLionExpressionType. - Evaluation — the decoded expression is passed to
evaluate, which dispatches to the appropriate handler. - Environment provision —
LionEnvironmentServiceis provided viaEffect.provideServiceEffect, wrappingenvironmentin a mutableRef-backed store sodefinecan update bindings at runtime.
Example
run provisions LionEnvironmentService internally, so the returned Effect
has no remaining requirements (never). You can pass it directly to
Effect.runPromise, Effect.runSync, or any other Effect runner without
additional setup.