CLC has approved the
proposal to remove (/=)
from class Eq
.
It means that class Eq
will contain a single member (==)
and (/=)
will
be just a normal function available from Prelude
.
Before:
class Eq a where
(==) :: a -> a -> Bool
(/=) :: a -> a -> Bool
After:
class Eq a where
(==) :: a -> a -> Bool
(/=) :: Eq a => a -> a -> Bool
The proposal was approved conditionally, pending a resolution of -Winline-rule-shadowing: Different for single and multi method classes? issue. At the very earliest the change may appear in GHC 9.8.
This is a breaking change, but of limited scope. If you import Prelude
in
full and either derive Eq
or define only (==)
in your instances, there is
nothing to change. An impact analysis showed that only 45 package of current
Stackage subset require updates, and thanks to @phadej we have all patches at
hand: https://gist.github.com/phadej/0e810832685cb4e70e3ca3a61e2f33d1
The migration policy for this change is backward-compatible: you can migrate already and still retain compatibility with existing GHCs. Because of this CLC suggests applying patches at your earliest convenience.
- If your code used to import
Eq(..)
fromPrelude
explicitly, please change
import Prelude (Eq(..))
to
import Prelude (Eq, (==), (/=))
- If your code used to import
Eq(..)
directly fromData.Eq
, please change
import Data.Eq (Eq(..))
to
import Data.Eq (Eq, (==), (/=))
- If your code used to define both members of
Eq
, just remove the definition of(/=)
, so that
instance Eq Foo where
x == y = foo x y
x /= y = bar x y
becomes
instance Eq Foo where
x == y = foo x y
- If your code used to define only
(/=)
, implement(==)
instead, so that
instance Eq Foo where
x /= y = foo x y
becomes
instance Eq Foo where
x == y = not (foo x y)
That's it!
Here is a template, which you can use when raising PRs against affected libraries.
Title: Future-proof class Eq
CLC has approved the proposal to remove
(/=)
fromclass Eq
(#3). It means thatclass Eq
will contain a single member(==)
and(/=)
will be just a normal function.The implementation of the proposal is delayed at least to GHC 9.4 and likely to GHC 9.6, but one can already future-proof code to be compliant with this change in a backwards-compatible way. No CPP required.
Migration guide and more info: https://github.com/haskell/core-libraries-committee/blob/main/guides/no-noneq-in-eq.md