fix ambiguous ContravariantShow[SortedSet[A]] (& SortedMap)
Fixes #4574 (I hope...)
Some good news: I've added tests for ContravariantShow implicit resolution and show interpolation for Set/SortedSet/BitSet and Map/SortedMap, and they look good to me (the solution was indeed to pull the superclass instances into parent traits and not the reverse).
Some less good news but it's okay, kinda: Duration/FiniteDuration have the same problem, where implicitly[Show.ContravariantShow[FiniteDuration]] pulls the Show[Duration] instance, and I've exhausted my (limited) bag of tricks (including moving stuff along the trait hierarchy and adding dummy value parameters) trying to make it not do that. On the other hand, the implementation of both Show[FiniteDuration] and Show[Duration] is Show.fromToString, so the "incorrect" instance behaves identically to the correct one. Although I feel it's a teeny tiny bit brittle to rely on that fact, there should never be an issue in practice.
Some less good news but it's okay, kinda: Duration/FiniteDuration have the same problem, where implicitly[Show.ContravariantShow[FiniteDuration]] pulls the Show[Duration] instance, and I've exhausted my (limited) bag of tricks (including moving stuff along the trait hierarchy and adding dummy value parameters) trying to make it not do that. On the other hand, the implementation of both Show[FiniteDuration] and Show[Duration] is Show.fromToString, so the "incorrect" instance behaves identically to the correct one. Although I feel it's a teeny tiny bit brittle to rely on that fact, there should never be an issue in practice.
If you're interested in resolving the theoretical issue with Duration and FiniteDuration, I think it should be enough to just swap their places. Did you try it?
If you're interested in resolving the theoretical issue with
DurationandFiniteDuration, I think it should be enough to just swap their places. Did you try it?
That is exactly the first thing I tried, and it results in ContravariantShow[Duration] eq ContravariantShow[FiniteDuration] being true.
That is exactly the first thing I tried, and it results in ContravariantShow[Duration] eq ContravariantShow[FiniteDuration] being true.
That's because it's the same lambda (fromToString) - LMF FTW
That is exactly the first thing I tried, and it results in ContravariantShow[Duration] eq ContravariantShow[FiniteDuration] being true.
That's because it's the same lambda (
fromToString) - LMF FTW
Not sure what "LMF" means, but then I realized that catsStdShowForDurationUnambiguous and catsStdShowForFiniteDurationUnambiguous are also the same instance, and I have no idea why. In any case that means I don't think I want to change anything regarding FiniteDuration/Duration. (If there's only going to be a single Show[Duration] value - also serving as Show[FiniteDuration] - in a given JVM, nothing bad will ever happen).
All in all, I'd say I'm done here.
Not sure what "LMF" means
LambdaMetafactory, used to implement lambdas on the JVM