WhyNotEqual.jl icon indicating copy to clipboard operation
WhyNotEqual.jl copied to clipboard

support more predicates, like `issetequal`

Open aplavin opened this issue 1 year ago • 2 comments

Currently, the predicate (== or another) is simply propagated and used to compare all parts of the object. It would be useful to also support stuff like whynot(issetequal, a, b) for collections. It should point to an element in one collection but not the other, and potentially find the "closest" match in the other collection to show differences there (using ==).

Do you think this is feasible to implement?

aplavin avatar Sep 08 '24 06:09 aplavin

Feasible yes, probably needs a big refactoring if we want to avoid complexity hell. If you are still interested, happy to discuss ideas.

jw3126 avatar Sep 08 '24 07:09 jw3126

Roughly we could do something like this. We allow the comparison function to not only return true, false but a reason why something is false. E.g. cmp(x,y)::Union{Bool, AbstractDiagnostic}. For instance AbstractDiagnostic could be a struct that tells two sets are not equal and holds the closest element.

We also add another indirection resolve_cmp that maps issetequal to such a comparison function with a custom diagnostic.

jw3126 avatar Sep 08 '24 07:09 jw3126