tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

70 lignes · 3863 octetsBrut · Historique

ADR 0001: Language surface and syntax

Status: Accepted — 2026-10-08, reviewed and accepted by the project owner (issue #2), including Revision 1.

Context

Louise (then named tilcayo, ADR 0021) combines Koka's typed algebraic effects, OTP's actors and supervision, Gleam's ergonomics (use, @extern, typed subjects), and JSX-like inline HTML.

The surface syntax has to:

  • read naturally to Rust and Gleam programmers,
  • embed HTML without ambiguity,
  • parse with good error recovery, because the LSP sees broken code most of the time.

Decision

Shape of the syntax:

  • Brace-delimited and expression-oriented: fn, let, match, pub, import a/b.{x, type T}.
  • One module per file.

Naming:

  • Types are Uppercase (Int, List<a>); type variables are lowercase.
  • Constructors are Uppercase.
  • Values and functions are snake_case.

Effect rows:

  • Written after the return type: fn f(x: Int) -> Int / <io, fail | e>.
  • An omitted row means total (pure).

Signatures:

  • pub fn requires a complete signature, including the effect row.
  • Private and local functions are inferred.
  • Required pub signatures make module interfaces stable, which keeps the LSP incremental, and keep error messages local.
  • The LSP offers an "insert inferred signature" code action.

Effects:

  • Declared with effect name { fn op(..) -> T ctl op(..) -> T final ctl op(..) -> T }.
  • Handled with handle { body } with { op(x) -> ..., return(x) -> ... }.

use:

  • Exactly Gleam's callback sugar: use a, b <- f(x) turns the rest of the block into f(x, fn(a, b) { rest }).
  • Combined with handler functions, use <- with_logger plays the role of Koka's with.

Generics and HTML:

  • Generic brackets <...> appear only in type positions, and there is no turbofish.
  • So < at the start of an expression always opens an HTML literal, which removes the JSX-style ambiguity.

Panics:

  • Not tracked in effect rows; a panic crashes the actor ("let it crash").
  • Recoverable errors use Result or a fail-style effect.

Consequences

  • The parser can be a hand-written recursive descent with a Pratt expression parser and no layout rule. That makes error recovery simpler than with Koka's indentation syntax.
  • Explicit type arguments in expressions are impossible. Annotations (let x: List<Int> = ...) cover that need.

Alternatives considered

  • Koka-style indentation syntax. Lighter to read, but layout rules complicate inline HTML and error recovery.
  • Gleam-style List(a) generics. That would free <>, but it reads as a call, and Koka users expect <> for effect rows.

Revision 1 — 2026-10-09: tail calls, tests next to code, derive

Status: Accepted — 2026-10-08, with the rest of this ADR (issue #2). Decided by the project owner.

  • Tail calls are guaranteed. Every call in tail position runs in constant stack (implementation in ADR 0003, Revision 1). Recursion is the loop construct, as in Scheme and Erlang.
  • Unit tests can live in the same file as the code, as in Rust:
    • @test fn adds_two() { ... } marks a test;
    • @should_panic("message") expects a panic, with an optional message fragment.
    • louise test runs every @test function of the package (src/ and test/), each in isolation.
    • Test functions are type-checked with everything else, so the LSP sees them, but they are never part of a program run with louise run or built with louise build.
  • @derive works like Rust's #[derive(...)], for the built-in traits Eq, Ord, Show (Rust's Debug), Hash and Default:
    • Default requires a single-constructor type whose fields all implement Default.
    • Clone/Copy have no equivalent: values are immutable, so sharing is free.
    • User-defined derives (Rust's procedural macros) need a macro system and come after v0.