(module mut_counter (fn main (doc "Sum 1..10 via a tail-recursive helper. Expected stdout: 55.") (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (app print (app sum_helper 1 10 0)))) (fn sum_helper (doc "Accumulator-style tail-recursive helper — sum from lo through hi inclusive.") (type (fn-type (params (con Int) (con Int) (con Int)) (ret (con Int)))) (params lo hi acc) (body (if (app gt lo hi) acc (tail-app sum_helper (app + lo 1) hi (app + acc lo))))))