Implemented equals and hash for constrained types