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

后端 未结 7 977
故里飘歌
故里飘歌 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:34

    I can't think of types that can't be compared.

    let infiniteLoop = infiniteLoop
    
    let iSolvedTheHaltingProblem f = f == infiniteLoop
    -- Oops!
    

提交回复
热议问题