|
Dedekind 0.0.0
A structuralist C++23 Module Library
|
Categorification of std::variant<A, B> as the categorical coproduct (A + B). More...
Categorification of std::variant<A, B> as the categorical coproduct (A + B).
A coproduct of A and B is an object C equipped with injection morphisms ι₁: A → C and ι₂: B → C such that for any object X with morphisms f: A → X and g: B → X, there exists a unique morphism v: C → X making the following diagram commute:
std::variant<A, B> satisfies this concept: any value of type A or B can be injected into the variant, and std::visit provides the universal elimination morphism.
Op-refinement (the injection factory Op::inl / Op::inr) is landed here for symmetry with IsProduct's pairing factory, but its consumer is not the set join (which is product-shaped). Its home is the set-expression collapse: the reduced-form outcome space {Ø, Singleton, Interval, Set, U} is a coproduct and each collapse rule is an injection into one summand (see #865, and the boundary injections Set{AlwaysTrue/False} == U/Ø in #685). The recursive case (fold over an initial F-algebra, ℕ = μX.1+X) is #449. Until one of those lands, the Op parameter is exercised only by its own witnesses.