I’m not sure I see the point in a polymorphic equal? in the first place. One of the usecases for (dynamic) polymorphism is that the interface can exist independently from the implementations and implementations can independently maintained. Comparing a to b is not a problem well suited to that if any of a or b are of arbitrary type, because both types need to interact to be compared, hence they’re no longer independent.
Elixir actually kinda has a polymophic option in that domain: Enum.sort can receive a module to do the comparison between items in order to sort elements of a list. It’s not officially a behaviour, but uses the single @callback compare(a, b) :: :lt | :eq | :gt. The big difference on that one – it’s not polymorphism on a per type level. Each passed module needs to be able to deal with all elements it gets thrown at for comparison and you won’t be able to later bring in a new struct and make it be handled differently.


















