; Iter 15a — first consumer of an stdlib module. ; Imports std_maybe, exercises from_maybe, is_some, is_none, map_maybe. ; First program to import a parameterised ADT (Maybe a) across module ; boundaries. prep.1 migration (kernel-extension-mechanics): every ; type-associated function on Maybe is now spelled in type-scoped form ; `Maybe.`, and bare `Maybe` is in scope via `(import std_maybe)` ; so the `term-ctor` type-name slot drops the module qualifier too. (module std_maybe_demo (import std_maybe) (fn inc (doc "Add 1 to an Int. Used as the (a -> b) arg to map_maybe.") (type (fn-type (params (own (con Int))) (ret (own (con Int))))) (params x) (body (app + x 1))) (fn main (doc "Drive each combinator once and print 7, 99, true, true, 42.") (type (fn-type (params) (ret (own (con Unit))) (effects IO))) (params) (body (seq (seq (app print (app Maybe.from_maybe 99 (term-ctor Maybe Just 7))) (do io/print_str "\n")) (seq (seq (app print (app Maybe.from_maybe 99 (term-ctor Maybe Nothing))) (do io/print_str "\n")) (seq (seq (app print (app Maybe.is_some (term-ctor Maybe Just 5))) (do io/print_str "\n")) (seq (seq (app print (app Maybe.is_none (term-ctor Maybe Nothing))) (do io/print_str "\n")) (seq (app print (app Maybe.from_maybe 0 (app Maybe.map_maybe inc (term-ctor Maybe Just 41)))) (do io/print_str "\n")))))))))