This was hidden within my previous reply to this post, but maybe we could do general multiple-dispatch via extensions to tuples, and institute tuple-conformance to Equatable
(and the rest) via that.
I know that functions that take an Optional
parameter can use a non-optional instance as an argument. Do tuples have the same relationship? I mean that is a tuple with at least one label member a sub-type of a tuple with the same shape but (at least) some labeled members become unlabeled? If so, we would define the tuple conformances to Equatable
as an extension on unlabeled tuples, and ones with at least one label would inherit that.
If we do implement Equatable
tuples as multiple dispatch, would we have to wait until variadic generics are implemented so we can define the extension just once? Otherwise, we need to extend Void
, then all two-member unlabeled tuples, three-member, etc. up to some limit like we do now with the tuple ==
functions. (The new definitions would still work better because, unlike the current function versions AFAIK, they would work when a member is itself a tuple.)