This patch changes code generation for derived Eq instances by comparing constructor tags. For this data type
data T = A | B Int | C Char
We now generate this code:
(==) a b = case dataToTag# a /= dataToTag# b of True -> False False -> case a of -- Here we already know that tags match B a1 -> case b of B b1 -> a1 == b1 -- Only one branch C a1 -> case b of C b1 -> a1 == b1 -- Only one branch _ -> True -- catch-all to match all nullary ctors
This produces less code - once we know that the tags match, we only need to emit 1 branch per constructor. It is also reasonable to think this should execute faster.
Squash / Update commit message