Lion
Lion is a JSON-based Lisp. Every Lion program is valid JSON, which makes it easy to serialize, store, inspect, and generate from other systems.
The evaluator runs on Effect v4.
Lion evaluates:
- JSON primitives directly
- strings as environment references when a binding exists
- arrays as special forms or function-call expressions
- unbound
"?name" strings as logic variables for relations, rules, and queries
- objects by recursively evaluating their values
The result is a small homoiconic language that can describe both computation and data interchange without a separate parser.
Packages
packages/
core/ evaluator, special forms, stdlib
cli/ Effect CLI executable for evaluating Lion JSON programs
typesafe-ai/ TypeSafe AI and Jev expression bindings
repl/ interactive graph editor
agent/ real-world Lion program driving an OpenTUI + AI agent
examples/ example Lion programs and the hosts that run them
site-runtime/ in-browser evaluator (Web Worker) for the live examples on lionlang.dev
metrics/ private tools that measure Lion's complexity, speed, and tests
history/ the project record and the research model of Lion's development
Graph Editor
@lionlang/repl is the Lion Fold Map: a local-first semantic graph editor for Lion JSON files. The JSON source remains canonical while the graph, diagnostics, and evaluation results track explicit document revisions.
bun install
bun run prepare
turbo dev --filter=@lionlang/repl
Open http://localhost:3000, import or open a Lion JSON file, and edit it in the graph: there is no text pane beside it, so you edit literals in their graph nodes or replace the selected expression with JSON. Run against the standard library, then save to the original file handle or download the exact source. See packages/repl/README.md for shortcuts, browser fallback behavior, verification, and architecture.
Command Line
Install @lionlang/cli in a project or globally:
bun add --dev @lionlang/cli
Evaluate a Lion JSON file, an inline expression with --eval (-e), or standard input (- or piped stdin), optionally injecting top-level JSON bindings with --bind (-b) or --bind-file (repeatable, preserving exact numbers):
bun run lion program.json
bun run lion -e '["number/add", 1, 2]'
bun run lion -b tax=0.07 --bind-file order=order.json price.json
echo '["number/add", 1, 2]' | bun run lion -
Keep a logic database in a file across runs with --database. Pass multiple files to run them atomically in order against one database, pass --read-only (-r) to explore without writing back, run lion inspect to summarize a database's ontology and counts as JSON, or run lion diff to compare two saved databases (or preview the impact of --apply / --eval steps in memory, including derived conclusions with --derived):
bun run lion setup.json more-facts.json --database store.json
bun run lion checks.json --database store.json
bun run lion --read-only --database store.json -e '["begin", ["fact", ["edge", "a", "z"]], ["find", "?x", ["path", "a", "?x"]]]'
bun run lion inspect store.json --derived
bun run lion diff before.json after.json --derived
bun run lion diff store.json --apply next-step.json --derived
The file is loaded before the programs run, so each program can use its relations without declaring them, and is saved afterwards as a snapshot program (one form and one fact per line) only if the file did not exist or the database changed (and --read-only was not given). A file that does not exist yet starts empty. If any program fails, such as one that would break an invariant saved in the file, the file is left as it was. Running the same setup again keeps one copy of each rule and invariant.
Read a program without running it, and print what is wrong with it, each with where it stands as a JSON pointer: a part that would fail when it runs (such as a malformed form, a misspelled namespaced name, a wrong-arity call to a standard function, declared relation or schema, immediate lambda, or unmutated defined lambda, invalid relation/query/invariant options, an unsafe rule head or find template, or a logic variable in a ground fact), as an error, and a part that is wrong though nothing fails (such as an unreachable or non-exhaustive match case, a cond branch after else, a duplicate lambda parameter, or a near-miss bare call head), as a warning. Pass --eval (-e), - / piped stdin, --bind / --bind-file, or --database (read-only, to validate calls against a saved database's relations and schemas without altering it). It exits with an error when there is an error: