; Iter 15d — third consumer demo. ; Imports std_either, exercises all five combinators. First demo to ; pass two function arguments to a single combinator (the eliminator ; `either`); first to drive a 3-type-var polymorphic fn end-to-end. ; prep.1 migration (kernel-extension-mechanics): std_either. -> ; Either.; bare Either via (import std_either). (module std_either_demo (import std_either) (fn inc (doc "Add 1 to an Int. Used as the function arg to map_right and either.") (type (fn-type (params (con Int)) (ret (con Int)))) (params x) (body (app + x 1))) (fn main (doc "Drive each std_either combinator. Expected outputs (per line): 42, 99, true, true, 42, 6, 101.") (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (seq (seq (app print (app Either.from_right 0 (term-ctor Either Right 42))) (do io/print_str "\n")) (seq (seq (app print (app Either.from_right 99 (term-ctor Either Left 7))) (do io/print_str "\n")) (seq (seq (app print (app Either.is_left (term-ctor Either Left 7))) (do io/print_str "\n")) (seq (seq (app print (app Either.is_right (term-ctor Either Right 42))) (do io/print_str "\n")) (seq (seq (app print (app Either.from_right 0 (app Either.map_right inc (term-ctor Either Right 41)))) (do io/print_str "\n")) (seq (seq (app print (app Either.either inc inc (term-ctor Either Left 5))) (do io/print_str "\n")) (seq (app print (app Either.either inc inc (term-ctor Either Right 100))) (do io/print_str "\n")))))))))))