Variadic types: "Same-element requirements are not yet supported"

I was really excited to replace a lot of my repetitive declarations like:

func combineLatest<B: Publisher, C: Publisher, D: Publisher, E: Publisher>(_ b: B, _ c: C, _ d: D, _ e: E) -> AnyPublisher<(Output, B.Output, C.Output, D.Output, E.Output), Failure>
    where Self.Failure == B.Failure, B.Failure == C.Failure, C.Failure == D.Failure, D.Failure == E.Failure { ... }

func combineLatest<B: Publisher, C: Publisher, D: Publisher, E: Publisher, F: Publisher>(_ b: B, _ c: C, _ d: D, _ e: E, _ f: F) -> AnyPublisher<(Output, B.Output, C.Output, D.Output, E.Output, F.Output), Failure>
    where Self.Failure == B.Failure, B.Failure == C.Failure, C.Failure == D.Failure, D.Failure == E.Failure, E.Failure == F.Failure { ... }
// repeat, adding more parameters up to nth arity...

With one declaration of something like:

func combineLatest<each PublisherType: Publisher>(_ publishers: repeat each PublisherType) -> AnyPublisher<(Output, repeat (each PublisherType).Output), Failure> where repeat  Failure == (each PublisherType).Failure { ... }

But I get the error: Same-element requirements are not yet supported
That 'yet' makes it seem like this is a limitation that might be lifted someday.
Is this part of a proposal that didn't get implemented completely, or is it an intentional limitation?
To ask another way, are there any concrete plans to lift this someday? Or would this require an evolution proposal to implement?

1 Like

I think I know how to fix the outstanding issues mentioned in the PR description, I just need to find a little time to get it over the finish line :slightly_smiling_face:

The design of same-element requirements is specified in SE-0393.

5 Likes

That's great news! Thanks for your work on this.

Wow, interesting. I was having a hard time figuring out which variadic proposal was the relevant one. Thanks for the link :slightly_smiling_face:

1 Like