SELSimple Expression Language
GitHub

SEL documentation

SEL is a small expression language for business rules with five implementations — Python, JavaScript, PHP, C++23 and Common Lisp — that give the same answer, in memory or translated for a database. Start wherever your question is.

Reading paths

If you want to… Read
know what SEL is and why it is shaped this way Overview
trust that five hosts really agree How parity is achieved and guaranteed
write rules Syntax → Operators → Functions
call SEL from an application Using SEL, then Validation or Scripting
filter rows in a database with a rule SQL conditions
run whole queries and data pipelines SQL pipelines, then the schema that looks like yours
look up a binding, a dialect or a refusal code SEL and SQL — reference
add functions, dialects or SQL spellings Extending SEL, then Your own functions, in SQL
change SEL itself Contributing

Contents

Start here

  • Overview — the problem, what a program is, the design principles, where SEL fits, what it leaves out
  • How parity is achieved and guaranteed — never the host's idea of a number or a string; generated artifacts; every layer of the gate

The language

  • Syntax — programs, names, values and kinds, numbers, text, lists and records, booleans, NULL, variables, binders, errors
  • Operators — precedence, exact arithmetic, the three comparison families, coalescing, assignment, the pipeline operator .>
  • Functions — control, aggregates, sorting, grouping, slicing, joins, null safety, text, numbers, binary, regular expressions

Using SEL — every snippet in five languages, quoted from programs the test suite runs

SEL and SQL

Extending

  • Extending SEL — host functions, dialects of your own, SQL spellings, and how a builtin joins the language
  • Contributing — the order of work, the argument and value APIs, operators, conformance cases, the traps each host has fallen into, the checks, a sixth host

Reference

Internals

Two ways to read this

These pages are Markdown, and read well on GitHub. The same pages are also a styled site — language tabs instead of five stacked code blocks, a navigation sidebar, dark mode:

sh
node tools/build-docs.mjs --serve 8080      # needs `npm install` once
docker build -f docs/Dockerfile -t sel-docs . && docker run --rm -p 8080:80 sel-docs

Every expr => result example on these pages is executed by all five implementations, every code block quoted from examples/ is compared with the file it came from, and every link is checked — the documentation is part of the test suite.

View this page's Markdown on GitHub