(module mut_sum_floats

  (fn main
    (doc "Float twin of mut_counter via a tail-recursive helper. Expected stdout: 55.0 (Float 55.0 via %g plus the runtime `.0`-fallback for finite whole-valued doubles, Gitea #7).")
    (type (fn-type (params) (ret (own (con Unit))) (effects IO)))
    (params)
    (body
      (app print (app sum_helper 1.0 10.0 0.0))))

  (fn sum_helper
    (doc "Accumulator-style tail-recursive Float helper — sum from lo through hi inclusive.")
    (type (fn-type (params (own (con Float)) (own (con Float)) (own (con Float))) (ret (own (con Float)))))
    (params lo hi acc)
    (body
      (if (app float_gt lo hi)
        acc
        (tail-app sum_helper (app + lo 1.0) hi (app + acc lo))))))
