When I refer to a OneOf type, I mean I mean a Variadic option type:
typealias MyType = OneOf<A, B, C>
to use MyType:
let myType = MyType(choosing: A())
To answer your question, I guess OneOf could allow that by requiring an index in its initialisation, but there are substantial drawbacks to doing that:
- A Tuple -
(Foo, Foo)or justFoo- would be the correct way to do that. - Features like "
myType as? A", "MyType(choosing: A())" would not be able to be added in the future without source-breaking changes. - It would be slower to do so - with run-time checks, and without compiler-errors it could be frustrating to get run-time ones.