The original intent is to address cases where single input Type is needed to be transformed into multiple Types, like this:
extension Sequence {
// curent imp:
func splitMap<T1, T2, E: Error>(_ transform: (Element) throws(E) -> Either<T1, T2>) rethrows -> ([T1], [T2]) // we are currently limited by 2 generic Types
// what we need is something like:
func splitMap<each T, E: Error>(_ transform: (Element) throws(E) -> OneOf<each T>) rethrows -> (repeat each Array<T>)
}
For now it is possible to implement a function with multiple input Types and single output Type by pack iteration which is already pitched and implemented.
func == <each Element: Equatable>(lhs: (repeat each Element), rhs: (repeat each Element)) -> Bool {
So some solution is also needed for the specified case.
You can poorly implement a variadic sum type with repeat Optional<each T>, which might be sufficient for something like this where you hope it all gets inlined away. I don’t think we’d put that in the stdlib though.