; Iter it.2 Phase-3 e2e: an it.2-clean structural recursion that ; actually RUNS. `sum` recurses on the Cons-tail `t` via a plain, ; non-tail `(app sum t)` — structurally guarded ⇒ the it.2 check ; classifies it pure + total, so it carries NO `!Diverge` and uses ; NO `tail-app` marker. This proves the structural-recursion ; classification is behaviourally sound end-to-end (the "total" ; verdict is not just a typecheck assertion): build [1,2,3,4,5], ; sum it structurally, print 15. (module struct_rec_sum_e2e (data IntList (ctor INil) (ctor ICons (con Int) (con IntList))) (fn sum (doc "Structural sum: plain non-tail recursion on the Cons tail. No !Diverge, no tail-app.") (type (fn-type (params (con IntList)) (ret (con Int)))) (params xs) (body (match xs (case (pat-ctor INil) 0) (case (pat-ctor ICons h t) (app + h (app sum t)))))) (fn main (doc "Build [1,2,3,4,5] and print its structural sum. Expected stdout: 15.") (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (app print (app sum (term-ctor IntList ICons 1 (term-ctor IntList ICons 2 (term-ctor IntList ICons 3 (term-ctor IntList ICons 4 (term-ctor IntList ICons 5 (term-ctor IntList INil)))))))))))