You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(types): add Echo types (structured loss) across the pipeline
Introduce `Echo<A, B>` — the fibre of a function A → B (a retained
witness `x : A` with `f x ≡ y : B`) — and its residue `EchoR<A, B>`,
porting the echo-types (Agda) / EchoTypes.jl lineage into Error-Lang as
a runnable, stability-aware model of non-total erasure.
Pipeline:
- Types/Lexer: `Echo`/`EchoR` keywords; `TyEcho`/`TyEchoResidue`
typeExpr with sugar (`Echo<A,B>`, `Echo<A>`, bare `Echo`).
- Parser: real `parseTypeExpr` (primitives, `Array<T>`, Echo/EchoR,
nested `>>` splitting) wired into let annotations, struct fields and
function params/return — annotations were previously dropped.
- TypeChecker: internal `TyEcho`/`TyEchoR` with conversion, display and
unification. Echo and EchoR unify only with their own kind and never
with each other, so erasure is irreversible at the type level.
Builtins mirror EchoTypes.jl: echo, echo_to_residue,
residue_strictly_loses, echo_input (illegal on a residue), echo_output.
- Runtime (Bytecode/VM/Codegen): `VEcho{input,output}` single-witness
value and `VResidue{output}`; dedicated opcodes. Erasing an Echo to its
residue debits stability (a Landauer-style cost; cf. fiber_erasure_bound).
- Pretty/LayerNavigator: render the new type forms.
- spec/type-system.md: new §7 (Echo Types) plus the [Stab-Erase] rule.
- Tests: type-checker, parser and lexer coverage for Echo/EchoR.
The core conversion/display/unification logic was compile-verified and
behaviourally checked in isolation (the wider compiler/ tree does not
build against mainstream ReScript for reasons predating this change).
0 commit comments