(module maybe_int (data Maybe (vars a) (doc "Optional value with a polymorphic payload.") (ctor None) (ctor Some a)) (fn or_else (doc "Returns the wrapped Int for Some(x) and the default d for None.") (type (fn-type (params (con Maybe (con Int)) (con Int)) (ret (con Int)))) (params m d) (body (match m (case (pat-ctor None) d) (case (pat-ctor Some x) x)))) (fn main (doc "Print or_else for both arms; expected 7 then 99.") (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (seq (seq (app print (app or_else (term-ctor Maybe Some 7) 99)) (do io/print_str "\n")) (seq (app print (app or_else (term-ctor Maybe None) 99)) (do io/print_str "\n"))))))