(module tail_recur_let_wrapped_no_leak_pin
  (data Box (ctor B (con Int)))
  (data IntList (ctor INil) (ctor ICons (con Int) (con IntList)))
  (fn run
    (type (fn-type (params (own (con Box)) (own (con IntList))) (ret (own (con Unit))) (effects IO)))
    (params b input)
    (body
      (match input
        (case (pat-ctor INil) (do io/print_str "done\n"))
        (case (pat-ctor ICons v rest)
          (let b_new (term-ctor Box B v)
            (tail-app run b_new rest))))))
  (fn main
    (type (fn-type (params) (ret (own (con Unit))) (effects IO)))
    (params)
    (body
      (let b (term-ctor Box B 0)
        (app run b (term-ctor IntList ICons 1 (term-ctor IntList ICons 2 (term-ctor IntList INil))))))))
