From c842611fc72d987519cd9fab1c351135ae93665e Mon Sep 17 00:00:00 2001 From: nineonine Date: Wed, 10 Nov 2021 00:52:06 -0800 Subject: Revamp derived Eq instance code generation (#17240) This patch improves code generation for derived Eq instances. The idea is to use 'dataToTag' to evaluate both arguments. This allows to 'short-circuit' when tags do not match. Unfortunately, inner evals are still present when we branch on tags. This is due to the way 'dataToTag#' primop evaluates its argument in the code generator. #21207 was created to explore further optimizations. Metric Decrease: LargeRecord --- testsuite/tests/deriving/should_fail/drvfail011.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testsuite/tests/deriving/should_fail') diff --git a/testsuite/tests/deriving/should_fail/drvfail011.stderr b/testsuite/tests/deriving/should_fail/drvfail011.stderr index d439bd03eb..5b26f5b575 100644 --- a/testsuite/tests/deriving/should_fail/drvfail011.stderr +++ b/testsuite/tests/deriving/should_fail/drvfail011.stderr @@ -3,8 +3,8 @@ drvfail011.hs:8:1: error: • No instance for (Eq a) arising from a use of ‘==’ Possible fix: add (Eq a) to the context of the instance declaration • In the expression: a1 == b1 - In an equation for ‘==’: (==) (T1 a1) (T1 b1) = ((a1 == b1)) + In a case alternative: (T1 b1) -> ((a1 == b1)) + In the expression: case b of (T1 b1) -> ((a1 == b1)) When typechecking the code for ‘==’ in a derived instance for ‘Eq (T a)’: To see the code I am typechecking, use -ddump-deriv - In the instance declaration for ‘Eq (T a)’ -- cgit v1.2.1