Status: approved and implemented on branch fx020 (2026-10-13 to
2026-10-14); not merged. The user approved this design in conversation on
2026-10-13, together with review refinements. As built: docs/adr/012-
effect-namespaces.md (one wording, the multi-candidate hint, awaits the
user’s approval). Sequencing: after Text v1, because both rework the
parser, and before Records (R001), because r.field must coexist with
Effect.op.
Operation names currently share one global namespace with functions, and collisions resolve silently and wrongly. Both cases below were reproduced on main on 2026-10-13:
effect Audit { fn log(n: Int): Unit; } together with effect Log
{ fn log(n: Int): Unit; } is accepted.log(…) then means Audit.log, so a function with Log that
calls log(1) is rejected with “work performs Audit, which its
signature does not allow”.Log.log is unreachable.effect Log { fn log(n: Int): Unit; } and fn log(n: Int): Int are
declared, every log(…) calls the function. The operation is
unreachable, and a call inside with Log reports Expected Unit, found
Int.Declaration uniqueness across effects is rejected by the user: independent
services must be able to reuse natural names such as get, log and
query.
Effect.op.
A bare operation name is never in scope by default. Rationale: adding
an effect elsewhere can never break existing code, because there is no
ambiguity rule to trip.with Database as D + Log { log, info as note }.Console.print and
Fail.fail, and with Console { print } gives the short form.
Built-ins get no special syntax or naming rules anywhere. Like
PureScript/Haskell, built-ins should be ordinary declarations wherever
possible.let shadow imports. Lambdas inherit them.Qualified operation call. Effect.op(args), for example
Database.query(id), Console.print(x) or Fail.fail(NotFound(3)).
Effect is the declared effect name (uppercase), or an alias in scope.r.name), so case alone distinguishes the two.S.get(), or
Fail.fail(e), whose family comes from the head of e’s type, exactly
as fail(e) does today.Operation references. A qualified operation is also a value. For
example, Database.query can be passed as an argument without being
called, as in map(Database.query, ids), exactly as a bare operation
reference (the compiler’s existing OperationRef) works today. An
imported bare name is a reference in the same way: with
Fail(Error) { fail }, fail may be passed as a value of the family’s
operation type.
Signature aliases and imports. These are allowed only in a function
declaration’s own row: the with of its final stage. They are scoped to
that function’s body. Alias or import syntax in any other written row is
an error (§3). Other written rows include:
The rule is that one row, one body, one scope. A function’s bindings are therefore all visible in its signature line. The forms, in order:
[nofail | nofail(k)] Effect[(args)] [as Alias] [{ op [as name], … }]
Database as D makes D a local alias of the effect.
Database.query remains valid alongside D.query, and the alias never
hides the canonical name.Log { log, info as note } binds the bare local names
log and note to Log.log and Log.info for the function body.Fail(Error) { fail } binds fail to the operation of that specific
family, so fail(x) requires x : Error. Fail(E1) { fail as fail1 }
together with Fail(E2) { fail as fail2 } imports two families under
two names.nofail Log { log }.Handlers are unchanged. In handler Log { log(n) => … } and
handle e { fail(error: E) => … }, clause heads name the handled
effect’s own operations. Clause bodies follow the ordinary rules, so a
body that performs Log writes Log.log or uses an import of the
enclosing function.
Database.query resolves to the declared operation whether or not
Database is written in the signature. Effect checking then decides
whether performing it is allowed, with the existing diagnostics.
Resolution therefore never depends on inferred rows (INF001).let bindings and lambda parameters.The first match wins, with no fallback. If the inner binding has the wrong type, the result is an ordinary type error at the use. It never silently falls through to an outer binding of the same name.
The texts below are approved by the user. The two that were marked pending were approved on 2026-10-13. The duplicate-binding errors are E_SYNTAX at the offending name, each with a note at the first binding.
{ log as note, info as note } conflicts: note is imported
twice in this signature, with the note first imported here.with Database as Log is rejected even when Log is absent from the
row, because otherwise Log.query would mean Database and contradict
canonical lookup.
Log is already an effect name.declared here at the effect declaration, or first bound
here at the earlier alias.Imports and aliases are allowed only in a
function's own row.x is not an operation of Log. It has no first-binding
note.Unbound bare operation names. These keep the existing unbound-name
error and code, with a hint attached in the existing hint form:
; use Log.log, or import it with Log { log }.
; use Audit.log or Log.log, or import one with
… { log }.print is Console.print and fail is Fail.fail, with no
exceptions.crash and show are not operations. They are global functions with
ordinary names.
crash is compiler-provided because it is a defect primitive.show is compiler-provided only until type classes (C001), and then
becomes an ordinary class method.Console or Fail collides with the built-in
declaration under the same rules as any duplicate declaration (existing
E_RESOLVE-family error).Effect.op is uppercase-qualified and r.field is
lowercase-receiver access. R001’s design must keep that distinction.Billing.Log.log), with imports at module level. This design’s
signature imports remain as the local form.Every existing program uses bare operation names: examples, hundreds of test programs, the reference interpreter’s corpus and the generator.
handler Log { log(n) => … }, fail(error: E)
=> …) are not rewritten.bootstrap/*.go snapshots, plus Text’s bootstrap/text.go
once Text lands, stay byte-identical;let and a lambda parameter each shadowing an import;{ log as note, info as note });Database.query in a
function whose row lacks Database resolves, then fails effect checking
with the existing diagnostic.Fail(E1) { fail as f1 } + Fail(E2) { fail
as f2 } checks each payload against its own family, and
Fail.fail(e) infers the family from e.map(Database.query,
ids). A reference to an imported Fail(Error) { fail } passed as a
value.npm run verify exits 0 under the usual rules.A survey of the compiler while writing the plan found four facts the design did not state. Each one is recorded here, and none adds user-facing text.
fail is a keyword today. The parser recognises fail(e) as its
own expression form (Syntax.Fail) before ordinary names. Under this
design, fail stops being syntax: Fail.fail(e), or an imported
fail, is an ordinary operation call whose family comes from e. The
handle clause head fail(error: E) => is a clause head naming the
handled effect’s operation, and it stays. This removes a special form,
in line with the principle that built-ins get no special syntax.Console.print, Fail.fail, imports and the
collision rule (§4) work uniformly.
print accepts any printable type, so it cannot be written as an
ordinary Waxwing declaration until type classes exist (C001).show, it stays compiler-provided. This is a recorded
temporary gap, not a design choice..wxw fixtures, and many tests pin exact columns
that a qualifier shifts. The migration therefore runs in reviewable
stages:
fail keyword are removed,
together with the unbound-name hint.Verify passes after every stage.