All code is valid JSON. All JSON is valid code. Serializable, homoiconic, and trivially parseable by any system.
["number/add", ["number/multiply", 3, 4], ["number/subtract", 10, 5]]
// Evaluates to: 17
A language designed for the modern web, where data and code seamlessly interoperate.
Code is data, data is code. Manipulate programs as easily as you manipulate JSON objects.
Store programs in databases, send them over APIs, or persist them to files. It's just JSON.
Add custom functions to the environment. Your functions become first-class citizens.
Built with Effect and Schema for runtime type validation and powerful error handling.
Any system that reads JSON can work with Lion programs. No special tooling required.
Expressions nest naturally. Build complex logic from simple, reusable building blocks.
Explore how Lion handles everything from basic arithmetic to complex logic.
Function calls use Lisp-style prefix notation within JSON arrays.
["number/add", 1, 2]
// => 3
["number/multiply", 5, 4]
// => 20
Use cond for multi-branch conditionals with pattern matching.
["cond",
[["number/greaterThan", "score", 90], "great"],
[["number/greaterThan", "score", 70], "pass"],
["else", "retry"]
]
Objects preserve keys and evaluate each value.
{
"sum": ["number/add", 1, 2],
"ok": true
}
// => { "sum": 3, "ok": true }
Create functions with lexical scope using lambda.
["lambda", ["x"], ["number/add", "x", 1]]
// Define and use:
["begin",
["define", "inc", ["lambda", ["x"], ["number/add", "x", 1]]],
["inc", 41]
]
// => 42
Extend stdlib with your own values and functions.
const env = {
...stdlib,
price: 100,
taxRate: 0.08,
clamp: (min, max, val) => Math.min(max, Math.max(min, val))
};
["number/add", "price", ["number/multiply", "price", "taxRate"]]
// => 108
Control evaluation with quote and eval special forms.
["quote", ["number/add", 1, 2]]
// => ["number/add", 1, 2]
["eval", ["quote", ["number/add", 1, 2]]]
// => 3
Start using Lion in your TypeScript projects today.
npm install @lionlang/core
import { Effect } from "effect";
import { run } from "@lionlang/core/evaluation/evaluate";
import { stdlib } from "@lionlang/core/modules";
const result = await Effect.runPromise(
run(["number/add", 1, 2], stdlib)
);
// => 3
const env = {
...stdlib,
price: 100,
taxRate: 0.08,
};
await Effect.runPromise(
run(["number/add", "price", ["number/multiply", "price", "taxRate"]], env)
);
// => 108
Join the community and start building with a language where code and data are one.