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.
ADR 0044: Effect-row ergonomics: row aliases and the /_> marker
Status: B (row aliases) Accepted (2026-10-23, issue #203) and implemented; C (the /_> marker) remains Proposed and needs engineering review (#44). B adds a declaration form and C relaxes a signature rule, so they change what the language accepts — the type checker keeps the same rows underneath.
Context
Effect rows keep Louise's guarantees visible, but they are verbose in a way that grows with an app. The examples/http_demo (587 lines) shows three distinct pains, analysed in the issue:
- Row repetition. The same rows repeat across sibling functions — the demo writes
<proc, random, io, ffi>five times instore.lsealone. Adding or dropping an effect means editing every site. - Handler-wrapper plumbing.
with_store(db, action: fn() -> a / <users, proc | e>) -> a / <proc | e>: the handled effect is listed in the parameter's row, the clauses' own effects in the wrapper's row, andethreads through both. This tax is paid per wrapper, and wrappers multiply as an app grows. - Order noise. Rows are sets (scoped duplicates aside, ADR 0008), yet the demo writes
<io, proc, ffi>in one place and<proc, random, io, ffi>in another — nothing to learn from the difference, everything to scan. (TheW0501dead-member lint, option A, already keeps rows honest as documentation; canonical order is a separate, smaller thing.)
What is already true and shapes the options: a function with no signature at all gets its row inferred; a signature with a result type but no row means total (E0502 otherwise) — that default is a feature, it catches effects you didn't mean to perform; pub fn requires a complete signature, API stability doing its job.
Decision
Two independent features, both leaving the type system's rows untouched.
B: row aliases
A new declaration form names a set of effects once:
pub effect alias app = proc, random, io, ffi
and a row may name it where a label goes: -> () / <app>, -> () / <app | e>, in a parameter's row too (fn() -> a / <users, app | e>). The alias expands to its members at name resolution: <app | e> is <proc, random, io, ffi | e>, so no typing rule changes — unification, subsumption and the W0501 lint see the expanded row. Aliases may not be recursive, may not take parameters (v1), and a member that is itself an alias expands transitively (a set, so duplicates collapse). Members resolve in the module that declares the alias, as a type alias's right-hand side does: a user imports only the alias, and the declaring module's imports count as used (issue #322).
Risks: indirection (a reader must know the alias; the LSP's hover expands it — noted as follow-up work); aliases outgrowing their uses (the dead-member lint gets coarser through an alias: it reports a member dead in the alias even where it is live in some other use — flagged here so review can weigh it).
C: the /_> marker
A signature with a result type but no row means total today. /_> keeps the rest of the signature explicit and infers only the row:
fn with_store(db, action: fn() -> a / <users, proc | e>) -> a / <_>
The body runs with the row a fresh unification variable that the body's effects fill (the same machinery that infers the whole row of a signature-less private function, ADR 0008); at generalisation the variable becomes a scheme row variable if it is still free — <proc | e> here: the clauses' proc, the action's forwarded e. So /_> is "infer the row, which may mention the signature's other row variables", and the wrapper's contract stays explicit in the parameter. _ is not a row variable today, so the syntax is free.
Restriction (v1): not on pub fn — a published signature spells out its contract. A recursive /_> function's self-call performs the body's own row, which is consistent; whether the row is principal is the review point below.
Consequences
- The demo's five
<proc, random, io, ffi>become<app>; adding an effect to the domain is one edit. The handler-wrapper tax (pain 2) mostly disappears where the wrapper only forwards a row. - The type checker is unchanged in its rows: aliases expand before it,
/_>uses the existing inference. Both are small, localisable changes (resolution and the signature path), which is the point of keeping them out of the row algebra. - The dead-member lint (option A) keeps the expanded rows honest.
Alternatives considered
- Inferring the row when omitted after
-> T: silently removes the declared-total check that catches unintended effects./_>gets the convenience without it. - Bundling std effects into one (
sys= io+clock+random+ffi): destroys the granularity that is the point of rows; the demo's tests rely on tellingiofromrandom. - Handler-declaration sugar (a
handlerform deriving the whole wrapper type from the handled effect and its clauses): removes the pattern entirely, but it is a new declaration form with real design surface (clause typing,ctl/final ctl, return clauses). Deferred until the two smaller ones have been lived with. - Canonical row order in diagnostics and
fmt: rows are sets except for scoped duplicates, so sorting is safe only when no label repeats — cheap to check; a formatting nicety, separable from this ADR, andfmt's charter is whitespace-only today. - Per-call-site effect annotations: more verbosity, not less.
Open for review
- Whether
/_>should stay out ofpubfor good (v1) or the row may be published inferred. - The alias's dead-member interaction (a member dead in the alias but live elsewhere), and hover expansion in the LSP.