Effect CommunityEC
Effect Community3y ago
21 replies
whatplan

The Importance of Hash Implementation for Equal in TypeScript

why does Equal require a Hash implementation?

if (isEqual(self) && isEqual(that)) {
  return Hash.hash(self) === Hash.hash(that) && self[symbol](that)
}

why is just self[symbol](that) not enough?
I understand that if that type implements Hash, the hashes should be the same if the objects are equal
But I could see a situation where you want to implement Equal for a type, but it is not necessary to implement Hash
Was this page helpful?