flatten
fn · Source line 36
pub fn flatten[T](v: T ! {none} ! {none}) -> T ! {none}One layer of absence removed: a doubly-absent value is absent, and an inner miss is absent too. The two misses are indistinguishable by construction — none carries no payload (§2), so there is nothing to tell an outer miss from an inner one, and a caller who needs to know wants two named tags rather than nesting.
Rows: raises none when either layer is absent. Total otherwise: no traps.
Example (prose — a row value has no literal, F-0038; runnable in tests/x/option_flatten/flatten_propagate.lu): with fn nest(x: int) -> int ! {none} ! {none}, option_flatten.flatten(nest(16)) else 0 - 1 is 4 and option_flatten.flatten(nest(6)) else 0 - 1 is -1.