You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support discriminated unions of alternative argument sets
An [<ArgParser>] type may now be a discriminated union, each of whose
cases holds one record of that case's arguments; and a record field may
be union-typed in the same way. Exactly one case's arguments must be
supplied: the case whose arguments appear is selected, arguments from
two cases are a conflict naming both witnesses, a selected-but-
incomplete case reports its own missing arguments, and when nothing
selects a case the unique case which needs no arguments (if there is
one) is chosen. Argument names must be globally unique across cases
(already enforced by the existing collision check), so selection never
depends on value conversion and parsing stays linear.
The erased runtime already understood Sum schemas (property-tested
against the exhaustive expand-every-alternative semantics); this wires
the generator up: union lowering in the parse tree, tree-shaped erased
schemas, selection-aware assembly (slots of unselected cases are never
read), and ParseOutcome.Success now carries the selection.
Generation-time checks, exercised in ArgParserConflictTests:
- at most one case of a union may be satisfiable with no arguments;
- positional args may not appear inside union cases, nor alongside a
union arg;
- the argument name "help" is reserved (it always meant help at
runtime; now generation refuses it too).
Help text for union schemas is currently the flat list of every case's
arguments; grouping it by case is a follow-up.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments