Skip to main content
Lion is a JSON-based Lisp library for TypeScript. Every Lion program is valid JSON, which means expressions are serializable, storable in a database, transmittable over a network, and generatable from other systems — all without a separate parser. The @lionlang/core package provides the evaluator, special forms, and standard library you need to embed Lion computation into any JavaScript project.

How the expression model works

Lion’s evaluation rules map directly onto JSON types:
  • Arrays are executable expressions. The first element is either a special form keyword or a function resolved from the environment; the remaining elements are arguments evaluated left to right.
  • Strings are environment references. When a binding exists in the current environment, the string evaluates to that value. When no binding exists, the string evaluates to itself.
  • Objects preserve their keys and evaluate each value recursively, producing a new plain object.
  • Primitives — numbers, booleans, and null — evaluate to themselves.
This means the same JSON structure is both data and code. You can inspect, generate, and transform Lion programs using ordinary JSON tools.

Key features

Homoiconic by design. Because programs are plain JSON, they share the same representation as data. You can quote, inspect, and pass programs as values without leaving the JSON format. Typed evaluation with Effect. The evaluator is built on Effect. Errors such as ArgumentMismatchError and InvalidFunctionCallError are typed values — not thrown exceptions — so error-handling is explicit and composable. Rich standard library. The stdlib export namespaces eight built-in modules: number, string, boolean, array, object, func, value, and console. Every entry follows the <module>/<name> convention, for example number/add or array/map. Seamless host interop. Extend the environment with any JavaScript value: plain objects, class instances, functions, or third-party APIs. Lion resolves strings against whatever you put in the environment, making it straightforward to drive JavaScript libraries from Lion programs. Special forms for control flow. define, lambda, cond, match, begin, quote, and eval give Lion expressive control flow while remaining representable as JSON arrays.

Where to go next

Quickstart

Install @lionlang/core and evaluate your first expression in under five minutes.

Expression model

Deep dive into how arrays, strings, objects, and primitives evaluate.

Standard library

Browse all built-in modules: number, string, array, object, and more.

Host interop

Call JavaScript methods, construct classes, and bind functions from Lion.