| 55 | 55 | Not fused: an effectful stage, `try_map`, `flat_map`, `zip`, or an intermediate used twice. A `perform`, `handle`, `region` or `defer` anywhere in a stage's function makes it effectful for this gate (a local `handle` that masks its own effect would do — the purity analysis is deliberately intraprocedural there, and can be revisited if real pipelines need it). |
| 57 | 57 | - **Purity is computed on Core**, not threaded from the type checker: Core is untyped, and after inlining the body is the truth. A function is pure when it performs no effect a `handle` of its own doesn't mask (the clauses recursively pure), opens no region, defers nothing, calls directly only pure functions and known pure closures, and calls externs only from the allocation-free list (`louise_perceus::fip::ALLOCATION_FREE`) plus the boxing float arithmetic — allocation is not observable (reference counting has no hooks), so it is not an effect. A greatest fixed point, so recursion between pure functions is pure. |
| 58 | +- **Panics are effects here; divergence is imprecise.** A crash is observable in Louise — a monitor sees `Crashed(message)`, a supervisor restarts (ADR 0004's "let it crash") — so a stage that can panic is never fused, whether the rule would reorder its panic or skip it. Divergence is imprecise, as in GHC: a pure stage that loops hangs fused or not (and `length ∘ map` can turn a hang into a result — nobody writes an intentionally divergent mapper). What may still change is when allocation happens, which nothing observes. The gate (`opt::pure`) requires: no `perform`/`handle`/`region`/`defer`, direct calls only to pure functions, externs only effect-free ones, and no panic — with a pragmatic carve-out the epic's own pipeline needs: division or a shift by a nonzero literal cannot panic (`x % 3` fuses). Since both back ends run the same optimised Core, they cannot disagree with each other. |
| 59 | 59 | - **Built-in rules, not a `@rule` attribute.** The shapes are few and stable; a user-facing rule language has a soundness surface of its own (confluence, ordering, proving LHS ≡ RHS) that a later ADR can bring. GHC's RULES are the precedent in both directions. Rules key on the std functions' identity as lowering records it (`WellKnown`, the way builtin effects are identified), not on names. |
| 61 | 61 | ### Constructed product results (issue #200) |