; Fieldtest kem.1 (Axis 1, type-scoped namespacing) — a consumer of
; std_list that drives several List.<fn> calls from one main. The
; LLM-natural shape is to spell every type-associated op with the
; type-name prefix (`List.length`, `List.fold_left`, `List.map`),
; not the module qualifier. Bare `List`/`Int` in type positions; bare
; ctor names `Cons`/`Nil` because the type is in scope via
; `(import std_list)`. The cycle's worked example for axis 1 is the
; std_maybe_demo migration; this example is the same shape over
; List<Int>, exercising a different home module and a function
; (fold_left) that takes a lambda — the LLM-natural shape there is to
; keep the lambda inline at the call site.

(module kem_1_list_running_sum

  (import std_list)

  (fn add
    (doc "Plain Int addition. Used as the (b, a) -> b arg to List.fold_left.")
    (type (fn-type (params (own (con Int)) (own (con Int))) (ret (own (con Int)))))
    (params acc x)
    (body (app + acc x)))

  (fn main
    (doc "Build a List<Int> of [1,2,3,4,5], print its length (5), then its sum (15).")
    (type (fn-type (params) (ret (own (con Unit))) (effects IO)))
    (params)
    (body
      (let xs
        (term-ctor List Cons 1
        (term-ctor List Cons 2
        (term-ctor List Cons 3
        (term-ctor List Cons 4
        (term-ctor List Cons 5
        (term-ctor List Nil))))))
        (seq (seq (app print (app List.length xs)) (do io/print_str "\n"))
             (seq (app print (app List.fold_left add 0 xs)) (do io/print_str "\n")))))))
