(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 (con IntList)) (ret (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 (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))))))