Checked Bend from Haskell, by fixed rules
cata writes Bend 2 by fixed rules: Haskell, Agda and specs in, Bend out. No model takes part; a module the rules cannot translate goes to a ledger with its reason. Where it can list inputs, each def it keeps is held to GHC's own answers as example laws, and its Bend is written back as Haskell to check the round trip.
Its name says the direction: cata folds a structure into Bend, so every file it writes can be rebuilt exactly from its input, and every file is checked by bend.
decidedWhat cata is: one deterministic Bend writer, with Haskell (new), Agda (agda2bend's fold) and specs as its inputs.cata PLAN.md, "Decisions" (2026-11-19), at 38d557b
Keys: → and ← move between pages, a shows every page at once. Each statement is marked: proved (BendTT's kernel, --verdict), tested (example laws or a comparison), measured, claimed, done, decided, lead or open.
No model in the loop, laws before code
| Rule | |
|---|---|
| 1 | No AI inside cata's loop. A module the rules do not take goes to the ledger with its reason, and the rules are fixed; no model repairs it. |
| 2 | Laws are frozen before code is generated, and the generator never edits them (Bend's own LAWS.bend / PROOF.bend rule). |
| 3 | Three levels of "checks" are never one label: --check-only, example laws, and a real proof (--verdict). |
| 4 | agda2bend's machine-named output is not pooled with cata hs's; the back end is shared. |
| 5 | Search-made programs are capped and deduplicated. |
| 6 | The 176-task test's functions are kept out of specs and translations. |
| 7 | No workarounds: no fuel to force termination, no arithmetic split over several U32s. Skipping is better. |
decidedLater, for telomare (2026-11-20, "Do not use unsafe"): recursion Bend refuses is written with a Nat fuel counted down from 2^32 − 1, as telomare's own Bend port writes it, never with @unsafe. PLAN.md keeps rule 7 beside it.cata PLAN.md, "Telomare's rules, 11", at 38d557b
Five programs, a ledger, and the way back
| Step | What it does |
|---|---|
tools/hs-export | Haskell, on GHC 9.10.3's API: type-checks a module and writes its typechecked syntax, every binder's type and every instance GHC chose, as S-expressions. It decides nothing. |
bend/Spec.bend | The specialiser: pattern synonyms and known view patterns made plain, and each call at closed types of a def with dictionaries written as a call of a copy, NAME__TYPES. |
bend/Survey.bend | Judges every binding against what the rules take, and says why each one out is out. |
bend/Fold.bend | Folds the bindings into Bend, keeps what bend --check-only accepts (a gate that takes out a failing def and whatever uses it), and ledgers the rest with its reason. |
bend/Law.bend | The fold plus example laws: small inputs by each def's Haskell type, GHC's interpreter runs the original, and each answer becomes a law the def must pass. |
bend/Back.bend | G, bend2hs: each module's kept items written back as Haskell (CATA_BEND2HS=1), with prelude/Back/BendRt.hs giving the prelude's names their Haskell meaning. |
| Ledger | Means |
|---|---|
| ok-law | the def checks and its example laws hold |
| ok-check | it checks, with no law (and why not) |
| ok-type | a type that checks |
| ok-gen | a def cata generated (a functor's cata, a lifted local, a type's ==) |
| out | not taken, with its reason |
doneShared with agda2bend: its Bend syntax tree, printer and S-expression reader (ToBend/) and Sys.bend, as bend/a2b.cata README.md, "Parts", at 38d557b
Haskell and Bend as categories: F there, G back
Types are the objects, programs (up to the same meaning) the arrows. hs2bend is F, from Haskell's programs to Bend's; bend2hs is G, back. Five flavours, weakest first, and what each one is in cata now:
| Flavour | In cata now | |
|---|---|---|
| 1 | F is a functor: compositional | a module's Bend is a function of its export and what its imports kept, so checks are cached by a Merkle digest |
| 2 | Commuting squares with meanings | [[F h]] = [[h]]: proved for every program and input on adj/'s model; on cata's own output, sampled by the example laws at GHC's answers |
| 3 | The way back: G(F(h)) against h | law by law, GHC the oracle: 7,139 of 7,147 the same on hs1003, 420 of 420 on telomare |
| 4 | An adjunction: "b correctly implements h" | F ⊣ G and G ⊣ F proved on adj/'s model; squares phi(F.h(x)) == W.b(phi(x)) proved for every x, on three pairings |
| 5 | Not an isomorphism | an equivalence on a fragment: what the ledger keeps, up to an iso |
provedOn adj/'s model of cata's fragment the adjunction is proved both ways, so F and G are an adjoint equivalence there; at Int and Integer, which F takes to Nat, G ⊣ F holds for every h that never subtracts (proved: such an h means at a non-negative value what it means at Natural, with the model's Int checked against GHC's), and F ⊣ G does not (the identity answers -1 at -1, where G's program errs). The proof is of the model, not of Fold.bend itself.cata PLAN.md, §4b, at 38d557b; adj/run.zsh, PASS
openF is not an isomorphism. F is not one to one on objects: Int, Integer and Natural are all Nat; (a, b, c) and (a, (b, c)) are the same nested Sigma; a partial h's A is Either<String, A>. So G(F(t)) is t only up to an iso, which BendRt's b'up undoes at h's type.cata PLAN.md, §3, at 38d557b
PLAN.md's own rule for these numbers: nothing is a proof unless it says --verdict.
Compositional, so its checks can be cached
F(g . f) = F(g) . F(f) at the level cata works at: bend's check of a file is a function of the file and its imports' files. bend/Cache.bend keys each check by a Merkle digest (SHA-256 of the file's text and its imports' digests) and each of GHC's answers by its script and the digest of the sources it reads (CATA_CACHE=DIR).
| Run | Time |
|---|---|
| telomare (31 modules), no cache | 168 s |
| the same, empty cache | 171 s |
| the same, warm cache (bend 0 calls, GHC 1) | 104 s |
| xmonad, no cache / warm | 10 s / 4 s |
measuredA cache filled by older rules (537a919), used by newer ones: 99 s against 155 s without it, 201 files, 0 differ.cata PLAN.md, §1, at 38d557b; tests/cache/cross.zsh, 29ced62
openCompositionality below the module does not hold yet: a def's check is its module's check, so one changed def costs its module's check, not its own.cata PLAN.md, §1, at 38d557b
G(F(h)) against h, law by law
An example law is a square at one point: at each input GHC answers, def f.exK() -> {F.f(x) == v : R}: {==}, and Bend computes both sides. G then writes F(h) back as Haskell, and each module's laws run again on G(F(h)), GHC the oracle.
| G on hs1003 | load in GHC | same | more defined | differ | missing |
|---|---|---|---|---|---|
| first version (da0e3dd) | 218 of 401 | 4,079 of 6,682 | (not told apart) | 19 | 2,584 |
| locals, strings, names (e100709) | 376 | 5,689 | 11 | 0 | 982 |
| the iso b'up, partial defs (bb64880) | 401 | 6,594 | 11 | 7 | 70 |
| h's number types from the export (3c0ee35) | 401 | 6,624 | 11 | 7 | 40 |
| synonyms expanded, kind variables dropped, triples converted (93f115a) | 401 | 6,671 | 11 | 0 | 0 |
| hs.map at a known function as a copy (46a5f9a) | 401 | 6,679 of 6,690 | 11 | 0 | 0 |
| Integer defaulting, b'pred as a successor (15bb4ff, before its division) | 7,100 of 7,131 | 23 | 0 | 8 | |
| division a failure value at 0 (15bb4ff) | 7,120 of 7,128 | 0 | 0 | 8 | |
| a guarded division total again (bc8b02b) | 415 of 416 | 7,119 of 7,127 | 0 | 0 | 8 |
| local pattern bindings, a lazy one floated in (1e155fd, 38d557b) | 415 of 416 | 7,139 of 7,147 | 0 | 0 | 8 |
tested"More defined" meant h errs where G(F(h)) answers, and every one was a division by 0: x mod 0 errs in Haskell, and the Base Nat.mod(x, 0n) F wrote is x. It looked like an adjunction's unit, h ⊑ G(F(h)); the proof on adj/'s model showed it was F's defect instead (F with total division is no left adjoint). With division a failure value at 0, none is left. No law answers in h and errs in G(F(h)).cata PLAN.md, §3, §4b, at 38d557b
openNot checked: G on Bend cata did not write (G reads the fold's syntax tree, not Bend's text).cata PLAN.md, §3, at 38d557b
F(G(b)) against b
G's Haskell goes through hs-export and law again, and each def of b is compared with F(G(b))'s: by its text (names as F writes G's, parameters by position), and where the text differs, by b's own laws.
| hs1003, b's 2,263 defs | defs |
|---|---|
| the same text | 1,366 |
other text, b's laws hold of F(G(b))'s def (--check-only; --verdict 78 of 82, 4 out of the kernel's fuel) | 82 |
| other text, no laws to decide | 95 |
| other text, b's laws do not apply (another type) | 30 |
| F refuses it | 690 |
provedF takes BendRt's wrappers back to the Base and prelude defs they stand for, each rewrite an instance of the wrapper's own definition: 105 laws, --verdict ALL PROOFS CHECK.875e8d7, its message
openWhat is left is F's own lack of injectivity on types: Int, Integer and Natural are all Nat, so G writes no number type for a def, and F refuses the class GHC then infers.cata PLAN.md, §3, at 38d557b
Squares, for every input and at GHC's answers
For a hand-written Bend b and a Haskell h, a square says phi(F.h(x)) == W.b(phi(x)): b does what h does, read through phi. tests/adjoint/run.zsh checks any pairing both ways: the squares' proofs, and each square at GHC's own answers for h (law's example laws give phi(v) == W.b(phi(a))), with mutants: two squares of one shape, their b's swapped.
| Pairing | Squares | --verdict | At GHC's answers | Mutants killed (answers / proofs) |
|---|---|---|---|---|
| XMonad.StackSet, xmonad-bend 1372ad9's StackSet | 17 | 17 (15 before fd.hm) | 23 of 23 | 0 / 2 of 2 |
| XMonad.Config, xmonad-bend 551bdaf's Core | 5 | 5 | 5 of 5 | 6 / 6 of 8 |
| hs1003 00038, a hand-written list | 3 | 3 | 21 of 21 | 2 / 2 of 2 |
provedThe 2 StackSet squares that were out of the kernel's scope needed a first-order copy of hs.map at a known function (as rule 15 copies foldr). cata now writes it (Fold's fd.hm), and all 17 pass --verdict, none out of scope; xmonad's and telomare's ledgers are the same line for line, G's 420 telomare laws the same.cata PLAN.md, §4, at 38d557b; 46a5f9a
openThe example points are weak where law's inputs are small: reverse and swapUp agree on every stack law tried, and only the proof tells them apart. The 2 Config mutants that survive are true squares (both flags are True).cata PLAN.md, §4, at 38d557b
On a model of cata's fragment, and what it changed in cata
adj/Core.bend is cata's fragment as two categories: Haskell's values and Bend's (numbers, booleans, unit, pairs, sums, lists), and programs point-free, so F's compositionality is its definition: identity, composition, projections and pairing, injections and case, literals, primitives, if, foldr (lists' initial algebra), and an error (Haskell) or a failure value (Bend). A program means a function from values to Maybe values, None the error. p ⊑ q when q answers what p answers wherever p answers. adj/PROPOSED.bend states the laws, adj/PROOF.bend proves them.
Proved by --verdict | |
|---|---|
| 1 | F and G are functors on the nose: identities, composition, pairs, sums, folds (a catamorphism goes to a catamorphism) |
| 2 | The squares for every program, by induction on it: F's Bend means what the Haskell means, G's Haskell what the Bend means |
| 3 | F ⊣ G: F h ⊑ b exactly when h ⊑ G b; and G ⊣ F: G b ⊑ h exactly when b ⊑ F h. An adjoint equivalence on this fragment |
| 4 | F as cata had it, with Base's total Nat.div and Nat.mod, is no left adjoint: x mod 0 errs everywhere, F of it answers 0 at 0 |
| 5 | At Int and Integer, which F takes to Nat: G ⊣ F for every h that agrees with its Natural meaning on non-negative values; F ⊣ G fails (the identity at -1) |
| 6 | Every h that never subtracts agrees (h at Int is the model's own Int arithmetic, + - < div mod), so G ⊣ F at Int needs no hypothesis; one that subtracts need not (x - y at (0, 1): an error at Natural, -1 at Int) |
| 7 | General recursion, with cata's fuel (Haskell's until p s, any loop): for every fuel n, F's fuelled def means what h means wherever h stops within n steps, and F ⊣ G on the loops that stop within the fuel; a loop that never stops breaks it (until (0 < 0) id: F's def answers its default 0) |
| 8 | Int's 64 bits: wherever a run stays in Int's range, GHC's Int (wrap-around, minBound div (-1) an error) answers what every integer does, so 5 and 6 hold of the real Int there; at any width, and at 2^63 − 1; the hypothesis is needed (x + x at 127 is −2 at Int8, 254 at every integer) |
| 9 | Laziness: wherever the strict meaning answers, Haskell's lazy one answers the same, so F's Bend is never wrong under laziness, at most less defined (fst (1, error) is 1 in Haskell, an error in F's Bend); in the lazy reading the adjunction needs strictness, and fails without it |
testedThe model's Int is GHC's, not one written for the proof: adj/IntGhc.hs has GHC write each of the 8 primitives' answers at all 81 pairs of -4..4 as Bend equations (adj/INT.bend), which Bend's checker and the kernel compute: ALL PROOFS CHECK, and a changed answer fails. And cata's survey refuses every way to a negative Int the proof's "never subtracts" stands for (tests/hs/IntNeg.hs: x - 1, subtract, negate, pred, x + (-3), complement, read, a call of a def that subtracts, via Integer, a downward range).cata PLAN.md, §4b (6), at 38d557b; c99f8f7
doneWhat the proof changed in cata: a div, mod, quot or rem by anything but a known non-zero literal, and Rational's /, is the prelude's partial HsNum, a failure value at 0 with GHC's own message; under an enclosing if x == 0 then .. else .. (or x /= 0, x > 0) the division by x stays total.15bb4ff, bc8b02b; cata README.md, "Partial functions", at 38d557b
testedIts effect: hs1003's "more defined" laws 23 → 0, tests/hs's 22 → 0 (1,046 laws, all the same), telomare's ledger line for line as before (420 laws the same). One def lost: 00482's op_pct, which passes (%) as a function value (a partial call under a lambda).cata PLAN.md, §4b, at 38d557b; bc8b02b
testedLaziness, closer: Bend is strict, so F's def failed where Haskell never forces a partial call (let h = head xs in if n == 0 then 0 else h at [] and 0). Fold's float-in now moves a let into the one branch that uses it, drops a let nothing uses and takes fst and snd of a pair written out, as GHC's own float-in does, so F's def answers there too and is never more defined than h. tests/hs/Lazy.hs: 2 defs ok-law before, 8 now, 64 laws the same; a strict let !x = e does not move (hs-export now keeps its bang); hs1003's and telomare's ledgers line for line, their laws the same.cata PLAN.md, §4b, at 38d557b; 7c2deef
testedThe model's Int8 and laziness are GHC's too: adj/IntGhc.hs also writes GHC's Int8 at its edges (minBound, maxBound and around them, 121 pairs, all 8 primitives) and adj/LazyGhc.hs GHC's answers, part by part, for 14 programs with an error inside a pair, a Left, a case, an if's other branch or a fold (adj/LAZY.bend); the kernel computes both against the model. Mutants (no wrap, every number in range, div at minBound by −1 answering, a strict pair, a fold's head the tail, an error that answers) each fail.cata PLAN.md, §4b (8), (9), at 38d557b; 1e155fd, de26318
openStill outside: an overflowing run (F answers the exact number where GHC's Int wraps, and nothing in cata guards it); a partial call Haskell never forces (F's def is less defined there, so its law fails and the def is out); cata's real G has no underflow guard at Int, so it is the model's only on non-negative inputs, which are the laws' inputs; and the proof is of the model, not of Fold.bend's code.cata PLAN.md, §4b, at 38d557b
An equivalence on a fragment, and copies as one transformation
testedOn the fragment the laws reach, the round trip is the identity up to the iso: of hs1003's 7,147 laws, 7,139 agree, none is more defined, none differs, and GHC refuses the other 8's lines.38d557b, its message
measuredThe specialiser copies a def at each type it is used at. In telomare: 165 defs copied, 808 copies by name, 199 of them fixing a function argument; with types erased, 727 distinct programs, 563 with the methods they call named by their def. So at least 245 of the 808 are another copy's program at another type, components of one natural transformation.cata PLAN.md, "Naturality", at 38d557b; a81a25d (law at bb64880)
provedOne copied def written once (telomare's bBasicEE, 9 copies: basicEE(T, L, ee, fw, x) = ee(fw(x))), a law proved once for every F, and a copy as its instance: --verdict ALL PROOFS CHECK, 3 laws.cata PLAN.md, "Naturality", at 38d557b; tests/natural
openThe kernel cannot take Telomare.Size's two copies (a module importing Telomare.PrettyPrint.Indent overflows bend's stack in the kernel's translation; one importing Telomare.Machine runs out of fuel on an example law), so cata's ok-law is a --check-only label, not a verdict. Whether Bend takes each merged def polymorphically is not checked.cata PLAN.md, "Naturality", at 38d557b
Recursion schemes, and recursion Bend refuses
Fix f,Cofree f aandCofreeF f a bare HsPrelude's generic types with the functor as a type function:Fix (PatternF t)isHsPrelude.Fix<(r_ => PatternF<T, r_>)>.- For each data type with a Functor instance, cata writes
G.cataandG.cata.cofree(ok-gen) as nested matches through the fields, which Bend sees shrink; not as an fmap, which Bend does not see through a template. - A cata whose algebra calls back its def, or at a functor with a list of its variable, is a def of its own at the call,
D.cH. - Recursion Bend refuses becomes
f.fu, aNatfuel one less at each self-call, called from 2^32 − 1, a depth no run reaches; at 0 it answers a default of its type. Defs that call each other are one def,HEAD.mu, over a sum of their arguments. Never@unsafe. - A layer of a monad's actions is a layer of functions, so each type with type variables has a twin,
D.fn, whose last variable is a Type.
Source: cata README.md, "Recursion schemes" and "Recursion Bend refuses: fuel".
testedtests/hs/Fuel.hs (halvings, digits, gcd', isEven/isOdd, a rose tree through its list, render/renderAll): 16 ok-law and 3 types, GHC agreeing; collatz, build and range out.cata PLAN.md, "Telomare's rules, 11", at 38d557b
Proved, tested, measured, open: pick a kind
Three levels of checks are never one label (rule 3): --check-only (Bend's checker accepts the file), example laws (GHC's answers, computed on both sides), and --verdict (BendTT's kernel, which has a proof in Lean).
Show
28 of 28
proved105 wrapper laws (BendRt's wrappers as the defs they stand for): --verdict ALL PROOFS CHECK.875e8d7
provedbBasicEE written once, its law proved once for every F, a telomare copy as its instance: --verdict, 3 laws.cata PLAN.md, "Naturality", at 38d557b
provedOn adj/'s model of cata's fragment: F and G are functors, the squares hold for every program, and F ⊣ G and G ⊣ F (an adjoint equivalence at Natural).cata PLAN.md, §4b, at 38d557b; 055c81d
provedF with Base's total division, as cata had it, is no left adjoint.cata PLAN.md, §4b, at 38d557b; 076c5bd
provedAt Int and Integer: G ⊣ F for every h that never subtracts, with no hypothesis left; F ⊣ G fails at -1.cata PLAN.md, §4b, at 38d557b; e55f896, c99f8f7
testedThe model's Int arithmetic is GHC's on all 81 pairs of -4..4, for each of its 8 primitives (computed by the kernel).cata PLAN.md, §4b (6), at 38d557b; adj/INT.bend, c99f8f7
provedGeneral recursion with fuel: F's fuelled def means what h means wherever h stops within the fuel; F ⊣ G on the programs that stop; refuted for one that never stops.cata PLAN.md, §4b (7), at 38d557b; 5fc1305
provedInt's 64 bits: where a run stays in Int's range, GHC's Int answers what every integer answers, at any width and at 2^63 − 1; refuted without the hypothesis (x + x at 127, Int8).cata PLAN.md, §4b (8), at 38d557b; 1e155fd
testedThe model's Int8 is GHC's at its edges: 121 pairs, 8 primitives (computed by the kernel).cata PLAN.md, §4b (8), at 38d557b; adj/INT.bend, 1e155fd
provedLaziness: wherever the strict meaning answers, the lazy one answers the same, so F's Bend is never wrong under Haskell's laziness; the adjunction in the lazy reading needs strictness (refuted at fst (1, failure)).cata PLAN.md, §4b (9), at 38d557b; de26318
testedThe model's laziness is GHC's on 14 programs, part by part (computed by the kernel).cata PLAN.md, §4b (9), at 38d557b; adj/LAZY.bend, de26318
provedxmonad-bend's StackSet against cata's XMonad.StackSet: 17 of 17 squares by --verdict (15 before fd.hm).cata PLAN.md, §4, at 38d557b; 46a5f9a
provedxmonad-bend's Core config against XMonad.Config: 5 of 5 squares by --verdict.cata PLAN.md, §4, at 38d557b; 4db79d0
provedhs1003 00038 against a hand-written list: 3 of 3 squares by --verdict.cata PLAN.md, §4, at 38d557b; e8d6caf
testedhs1003's round trip G(F(h)): 7,139 of 7,147 laws the same, 0 more defined, 0 differ, 8 missing.38d557b, its message
testedcata's own tests/hs: 1,198 laws through G(F(h)), all the same (22 more defined before division became partial).38d557b, its message; cata PLAN.md, §4b, at 38d557b
testedF(G(b)) against b on hs1003: 1,366 of 2,263 defs the same text, 82 equal by b's laws.cata PLAN.md, §3, at 38d557b; 875e8d7
testedtelomare's round trip on a package: 420 of 420 laws the same, 0 differ, 0 missing; all 31 of G's modules compile.1d90544; again at bc8b02b
testedhs1003's example laws: 1,360 defs ok-law with 4,781 laws (law7).cata PLAN.md, "Records, and one gate", at 38d557b
testedok-law is --check-only plus example laws: a label, not a verdict.cata PLAN.md, "Naturality"; rule 3, at 38d557b
measuredThe cache: telomare 168 s with none, 104 s warm; every file the same.cata PLAN.md, §1, at 38d557b; 0fc4a33
measuredAt least 245 of telomare's 808 copies are another copy's program at another type.cata PLAN.md, "Naturality", at 38d557b; a81a25d
openThe adjunction is proved of the model, not of Fold.bend's code; where the model says F differs (an overflowing run, a partial call Haskell never forces) cata does not guard it.cata PLAN.md, §4b, at 38d557b
openF is not an isomorphism: Int, Integer and Natural are all Nat; tuples nest; a partial h answers an Either.cata PLAN.md, §3, §5, at 38d557b
openG on Bend cata did not write is not checked.cata PLAN.md, §3, at 38d557b
openCompositionality below the module: one changed def costs its module's check.cata PLAN.md, §1, at 38d557b
claimedNo model takes part in the translation: a module the rules cannot take is ledgered with its reason.cata README.md, its opening, at 38d557b
leadA G that wrote h's own types would close most of F(G(b))'s refusals; so would laws equating BendRt's non-wrapper defs with the prelude's.cata PLAN.md, §3, at 38d557b
A whole package, rule by rule
measuredhs-export --package loads telomare master's library (28 modules, Haskell2010) in 4 s and writes each module in dependency order; survey, fold and law read them in that order, each module seeing what the ones before it kept.cata PLAN.md, "Packages: telomare master" (2026-11-19), at 38d557b; d38a9ca
| After | Out | ok-law |
|---|---|---|
| the first package run (law-pk2) | 755 | 55 |
| rule 1: Fix, Cofree, recursion schemes | 732 | 55 |
| rule 5: Data.Map, Set, IntMap, IntSet | 668 | 64 |
| rules 6–8: the specialiser, signed Int, SHA-256 | 573 | 80 |
| rule 13: a def's own name as a value | 502 | 95 |
| rule 18: Rational, list comprehensions | 455 | 97 |
| rule 19, telomare's own defs only from here | 446 | 98 |
| rule 26: a local named as a def | 423 | 100 |
| rule 29: an instance over a type variable | 415 | 103 |
testedAt 8bfb514 the ledger is 1,542 ok-check, 118 ok-law, 115 ok-type, 735 out; of the 420 laws on the 118 ok-law defs, 350 are the same through G(F(h)), 0 more defined, 0 differ, 70 missing (24 in EAL, whose Rational BendRt lacked; 46 lines GHC refused). It was 25 of 420.8bfb514, its message
testedThen with megaparsec and Rational on G's side: all 420 laws the same through G(F(h)), 0 differ, 0 missing, and all 31 of G's modules compile. Making division partial at 0 left telomare's ledger line for line the same, its 420 laws too.1d90544, its message; cata PLAN.md, §4b, at 38d557b
leadFor telomare's runtime: cata gives the hand-written Bend port a checkable spec from master's Haskell, and the square checker could pair the port's modules with master's as it pairs xmonad-bend's.telomare.hhefesto.dev, "How cata can help, 2"
643 small Haskell modules
measuredGHC 9.10.3 type-checks 637 of the 643 modules on disk. Of the 4,862 bindings other than main, the rules' first version takes about half (2,475). That is the survey's judgement of what the rules take, not a translation: the fold loses more.cata PLAN.md, "Step 1 results" (2026-11-19), at 38d557b
| hs1003, all 643 modules (law7, 53 s) | defs |
|---|---|
| check, and every example law holds (ok-law) | 1,360 (4,781 laws) |
| check, no law: a function argument | 128 |
| … a Float argument or result | 44 |
| … GHC gave no answer in 2 s | 16 |
| … no input | 13 |
| … the one gate lost every def | 1 |
| types | 558 |
| out | 3,224 |
testedThe laws catch what Bend's check cannot: the fold as it was at db802bf, run through the same laws on module 00303, loses mult1, mult2, mult3 and waxOn, each to its first law (expected : 70n | observed : 30n), and keeps the four defs that were right.cata PLAN.md, "Example laws", at 38d557b
A Hackage package, and a port written by hand
measuredxmonad 0.18.1 through cata, its first run: 931 bindings; ok-law 25, ok-check 24, ok-type 17, out 865.044c139, its message
claimedcata translated 66 of xmonad's 931 functions on its own; the rest stop on X11's types, == and compare at a type variable, pattern guards and guards with no fallback. So xmonad-bend's pure core is written by hand, function by function from XMonad/StackSet.hs and XMonad/Layout.hs.xmonad-bend (github.com/hhefesto/bxmonad) README.md, 639a3d6
testedThe port is checked against xmonad itself end to end: 3,314 steps, every one the same on both.bxmonad README.md, 639a3d6
provedAnd cata checks the hand-written side against its own fold of xmonad: 15 of 17 StackSet squares and 5 of 5 Config squares by --verdict.cata PLAN.md, §4, at 38d557b
cata's tests/xmonad/run.zsh takes any Hackage package the same way (hs-export, spec, survey, law); xmobar's library goes through it too (044c139), with no numbers recorded.
Five days, 79 commits
| Date | Commits | What |
|---|---|---|
| 11-19 | 12 | hs-export and the survey (de78a44); the fold (0b83518); example laws (536546d); packages: telomare master goes through cata (d38a9ca) |
| 11-20 | 19 | the specialiser (3c63853); monads, maps and sets, signed Int, SHA-256, Show; recursion with fuel (7df81e0); rules 12 to 21 |
| 11-21 | 8 | rules 22 to 29: Show at Fix, local catas, partial functions as failure values |
| 11-22 | 19 | speed (c2041aa, 74fe57b); the cache (0fc4a33); G, the way back (da0e3dd to 93f115a); naturality (a81a25d); the square checker (4db79d0) |
| 11-23 | 21 | F(G(b)) (875e8d7); a third pairing (e8d6caf); G on a package: telomare 25 → 350 → 420 of 420 (8bfb514, 1d90544); one copy per package (8932c1a); hs.map's copies, all 17 StackSet squares (46a5f9a); the adjunction on a model (076c5bd, 055c81d, e55f896), its Int hypothesis proved (c99f8f7); division partial at 0 (15bb4ff, bc8b02b); float-in, laziness closer (7c2deef); general recursion with fuel, Int's 64 bits and laziness in the model (5fc1305, 1e155fd, de26318); local pattern bindings, a lazy one floated in (1e155fd, 38d557b) |
measuredSpeed on telomare: the fold's search for mutual recursion was n^3 map lookups, now n^2, and the law run takes 315 s, not 51 minutes; then 286 s → 187 s (its fold 141 s → 50 s), every output the same.c2041aa and 74fe57b, their messages
What cata does not take yet
- Recursion through a function value (
map f xsinsidef): Bend's templates take only closed arguments, and the fuel is not one (rec-value). - A partial call under a lambda: a monad's continuation, a function argument, a cata's algebra (
fold:partial-in-lambda); since division became partial at 0,(%)passed as a value too (00482's op_pct). - Recursion with fuel answers a default when the fuel ends, so the adjunction's proof covers terminating programs only.
- A lazy list: a partial call in map's elements, never forced in Haskell (
length (map (div 10) xs)), still fails F's def; and a strictlet !x = eis out (fold:form). - Other monads: ExceptT over anything but State, IO, a type variable;
<*>at ExceptT. - Show at a list or a Maybe of the package's own type or of a Fix, at Map and Set;
<,compare,maxat the module's own types (fold:ord-at-type). - Int's 64-bit wrap-around is not modelled; an HsInt is a sign and a Nat up to 2^48 − 1.
Source: cata README.md ("Recursion Bend refuses", "Partial functions", "Monads", "Containers", "Equality").
openThe squares and their proofs are written by a person or an AI; the checker finds none. And law's inputs are few (at most 8 per def, small): too few to tell reverse from swapUp.cata PLAN.md, §4, at 38d557b
Made with bend-frp
The pages are data in Bend (Deck.bend); bend-frp runs the page, Nav.bend moves between pages, and "What holds" is sorted by Doc.bend's pick.
provedIts laws: moving never changes the number of pages, next then back returns where you were, going to page k from anywhere lands on k, the keys and addresses mean what this page says, "all" shows every fact and a kind shows only facts of that kind, and every claim, table, card and fact names a source. bend PROOF.bend --verdict prints ALL PROOFS CHECK.cata-site's LAWS.bend and PROOF.bend