Re:Upcoming/proposed breaking changes to Haskell
by toomanydoubts on Sunday November 21, 2021 @10:56AM
(#29297106)
I had never looked at the definition of Eq. Interesting. How are these operators expanded and evaluated without falling into infinite recursion?
Re:Upcoming/proposed breaking changes to Haskell
by olliej on Wednesday November 17, 2021 @08:08PM
(#29260969)
that's a default implementation, however it's not true for every type, hence custom implementations
Re:Upcoming/proposed breaking changes to Haskell
by kreetx on Thursday November 18, 2021 @03:49AM
(#29263455)
Right. With the current situation you could define a custom /= for every type. In the new situation /= is a regular function which is defined as `a /= b = not (a == b)` and you wouldn't be able to redefine it.
The way this works is that when you implement the `Eq` typeclass for a type, you can provide more specific implementations. A minimal complete implementation is to implement either == or /= for your type, and the other definition will apply.
The way this breaks existing code (iiuc) is that as a top-level function, if you have imported the `Eq` type class but haven't imported the `Prelude` module implicitly (on by default but can be turned off), you will not have `/=` in scope anymore.
I think people are upset by this less because of how hard it would be to fix, but more because of how it acts as a sort of signaling change ("they're willing to break my code for this, which I didn't want, but not for X which I did"). The most common value of X I've seen is removing or reworking the partial functions in the Prelude (e.g., head / tail on `[a]` raising an exception instead of returning `Maybe a`).