(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 (own (con Maybe (con Int))) (own (con Int))) (ret (own (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 (own (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"))))))
