In Haskell, equality test is normally performed using ==
coming the Eq
class. This function is (in most cases) defined under pure Haskell terms, so it follows all consequences of applying it recursively to big data structures. Therefore, a seemingly trivial comparison can take significant amount of time. Come on, this should be instant (reminder about laziness):
ghci> let x = [1..100000000] in x == x
True
(2.81 secs, 14,400,130,800 bytes)
Why doesn't Haskell use comparison by reference here? Does Haskell even allow me to do so if I really want to?