The value of a type that implements Eq can only be compared with another value of the same type โ not any other type that implements Eq . Therefore, if you have two values โโof different types, you cannot compare them, even if they are both instances of Shape (and therefore Eq ). Therefore, it is also impossible to have an Eq instance for Object , because an Object can contain values โโof different types - at least using instances of type instances.
You will need a function like (Shape a, Shape b) => a -> b -> Bool , which can be used to compare any shape with any other shape. If you have such a function, you can use it to create an Eq instance for Object . However, you cannot define such a function in such a way that it matches instances of Eq types.
sepp2k
source share