Commit bc907262 authored by Chaitanya Koparkar's avatar Chaitanya Koparkar Committed by Ben Gamari

Fix #10859 by using foldr1 while deriving Eq instances

Summary:
Previously, we were using foldl1 instead, which led to the derived
code to be wrongly associated.

Test Plan: ./validate

Reviewers: RyanGlScott, nomeata, simonpj, bgamari

Reviewed By: RyanGlScott, nomeata

Subscribers: rwbarton, carter

GHC Trac Issues: #10859

Differential Revision: https://phabricator.haskell.org/D5104

(cherry picked from commit 2d953a60)
parent ebc8ebf8
......@@ -214,7 +214,9 @@ gen_Eq_binds loc tycon = do
where
nested_eq_expr [] [] [] = true_Expr
nested_eq_expr tys as bs
= foldl1 and_Expr (zipWith3Equal "nested_eq" nested_eq tys as bs)
= foldr1 and_Expr (zipWith3Equal "nested_eq" nested_eq tys as bs)
-- Using 'foldr1' here ensures that the derived code is correctly
-- associated. See Trac #10859.
where
nested_eq ty a b = nlHsPar (eq_Expr tycon ty (nlHsVar a) (nlHsVar b))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment