A language a checker can refuse

Models write it. The compiler runs the examples.

Lingua is a small language in the Python and TypeScript mold (fn, match, List<T>, double-quoted strings, blocks closed with end). Source files are .lf. Every function except main has an example above the body, and the compiler runs it. Nominal types and bounded integers do not interchange. Expected failures are Result. assert and fail do not catch. lingua build emits one static linux/amd64 executable. The normative spec is docs/lingua1.md in the compiler repository.

Extension
.lf
Examples
Required, and executed
Types
Nominal
Integers
Bounded
Output
One static binary
License
CC0

01 — Language

Rails the checker enforces

  • Example before the body

    Every function except main has an example above the body, and the compiler runs it.

  • Named closers

    A declaration closes with its kind and name, as in end fn factorial.

  • Bounded integers

    An integer type has an inclusive range, and a tighter range is not introduced implicitly.

  • Nominal types

    type CustomerId = Text and type Cursor = Text do not unify.

  • Closed matches

    A match on a closed type has to cover every variant.

  • Declared effects

    A function declares its effects, and pure declares none.

  • Comptime

    An ordinary function runs at compile time when the call is marked comptime.

  • check, fmt, pack, build

    lingua check typechecks and runs examples, lingua fmt rewrites source into canonical layout, lingua pack prints a file with the signatures it needs, and lingua build emits one static linux/amd64 executable.

02 — Pipeline

Six columns from one program

Captured from the factorial program in the compiler's end-to-end tests.

  1. Tokens

    The lexer prints one token per line, with its line and column.

  2. AST

    The parser prints the untyped tree as an S-expression.

  3. TIR

    The typechecker prints the typed IR, with a type on every expression.

  4. LIR

    Build lowers the checked program into this form.

  5. Assembly

    The linux/amd64 backend selects these instructions.

  6. Run

    The sample prints 0! through 5!, then 20!.

Playground