Why isn't every type part of Eq in Haskell?

后端 未结 7 956
故里飘歌
故里飘歌 2020-12-31 04:48

Or rather, why isn\'t (==) usable on every data type? Why do we have to derive Eq ourseleves? In other languages, such as Python, C++, and surely o

7条回答
  •  粉色の甜心
    2020-12-31 05:28

    Because the way that values are compared may be custom. For example, certain "fields" might be excluded from comparison.

    Or consider a type representing a case-insensitive string. Such a type would not want to compare the Chars it contains for identity.

提交回复
热议问题