(module t4_count_zeros
  (data List (vars a)
    (ctor Nil)
    (ctor Cons a (con List)))
  (fn count_zeros
    (doc "Count zeros in an Int list using the prelude Eq Int instance.")
    (type (fn-type (params (con List)) (ret (con Int)))
    (params xs)
    (body (match xs
      (case (pat-ctor Nil) 0)
      (case (pat-ctor Cons h t) (if (app == h 0) (app + 1 (app count_zeros t)) (app count_zeros t))))))
  (fn main
    (doc "Print count_zeros(Nil) and count_zeros(Cons(0, Cons(5, Cons(0, Cons(3, Cons(0, Nil)))))) each on its own line.")
    (type (fn-type (params) (ret (con Unit)) (effects IO)))
    (params)
    (body (seq (do io/print_int (app count_zeros (ctor List Nil)))
      (seq (do io/print_int (app count_zeros (ctor List Cons 0 (ctor List Cons 5 (ctor List Cons 0 (ctor List Cons 3 (ctor List Cons 0 (ctor List Nil)))))) (unit))))))
)