(module list
  (data IntList
    (doc "Einfach verkettete Int-Liste, boxed.")
    (ctor Nil)
    (ctor Cons (con Int) (con IntList)))
  (fn sum_list
    (doc "Summiert die Elemente einer Int-Liste rekursiv.")
    (type (fn-type (params (own (con IntList))) (ret (own (con Int)))))
    (params xs)
    (body (match xs
      (case (pat-ctor Nil) 0)
      (case (pat-ctor Cons h t) (app + h (app sum_list t))))))
  (fn main
    (doc "Baut [10, 20, 12] und druckt die Summe (42).")
    (type (fn-type (params) (ret (own (con Unit))) (effects IO)))
    (params)
    (body (let xs (term-ctor IntList Cons 10 (term-ctor IntList Cons 20 (term-ctor IntList Cons 12 (term-ctor IntList Nil)))) (app print (app sum_list xs))))))
