; Iter 15g (refactored in 15g-aux) — fifth consumer demo. Imports four ; stdlib modules (std_list, std_either, std_pair, std_either_list); ; threads a List> through three combinators that ; together exercise every monomorphisation site introduced by 15g. ; ; The list is constructed inline by mixing `(term-ctor Either ; Left ...)` and `(... Right ...)`. Iter 15g surfaced a `unify_for_subst` ; asymmetry that would have rejected this construction at synth time; ; 15g-aux fixed it by accepting `$u` synth-wildcards on either side of ; the param/arg unification (see ailang-codegen/src/lib.rs's ; `unify_for_subst`). This demo is the regression fixture: if the ; symmetric early-return is reverted, the inline form below errors out ; before reaching codegen. (module std_either_list_demo (import std_list) (import std_either) (import std_pair) (import std_either_list) (fn main (doc "Drive lefts, rights, and partition_eithers on the same five-element List> (Left 1, Right 10, Left 2, Right 20, Right 30). Expected output (one per line): 2, 3, 2, 3.") (type (fn-type (params) (ret (con Unit)) (effects IO))) (params) (body (seq (seq (app print (app List.length (app std_either_list.lefts (term-ctor List Cons (term-ctor Either Left 1) (term-ctor List Cons (term-ctor Either Right 10) (term-ctor List Cons (term-ctor Either Left 2) (term-ctor List Cons (term-ctor Either Right 20) (term-ctor List Cons (term-ctor Either Right 30) (term-ctor List Nil))))))))) (do io/print_str "\n")) (seq (seq (app print (app List.length (app std_either_list.rights (term-ctor List Cons (term-ctor Either Left 1) (term-ctor List Cons (term-ctor Either Right 10) (term-ctor List Cons (term-ctor Either Left 2) (term-ctor List Cons (term-ctor Either Right 20) (term-ctor List Cons (term-ctor Either Right 30) (term-ctor List Nil))))))))) (do io/print_str "\n")) (seq (seq (app print (app List.length (app Pair.fst (app std_either_list.partition_eithers (term-ctor List Cons (term-ctor Either Left 1) (term-ctor List Cons (term-ctor Either Right 10) (term-ctor List Cons (term-ctor Either Left 2) (term-ctor List Cons (term-ctor Either Right 20) (term-ctor List Cons (term-ctor Either Right 30) (term-ctor List Nil)))))))))) (do io/print_str "\n")) (seq (app print (app List.length (app Pair.snd (app std_either_list.partition_eithers (term-ctor List Cons (term-ctor Either Left 1) (term-ctor List Cons (term-ctor Either Right 10) (term-ctor List Cons (term-ctor Either Left 2) (term-ctor List Cons (term-ctor Either Right 20) (term-ctor List Cons (term-ctor Either Right 30) (term-ctor List Nil)))))))))) (do io/print_str "\n"))))))))