From 32973bf3c2f6fe00e01b44a63ac1904080466938 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Mon, 5 Jan 2015 13:20:48 +0000 Subject: Major patch to add -fwarn-redundant-constraints The idea was promted by Trac #9939, but it was Christmas, so I did some recreational programming that went much further. The idea is to warn when a constraint in a user-supplied context is redundant. Everything is described in detail in Note [Tracking redundant constraints] in TcSimplify. Main changes: * The new ic_status field in an implication, of type ImplicStatus. It replaces ic_insol, and includes information about redundant constraints. * New function TcSimplify.setImplicationStatus sets the ic_status. * TcSigInfo has sig_report_redundant field to say whenther a redundant constraint should be reported; and similarly the FunSigCtxt constructor of UserTypeCtxt * EvBinds has a field eb_is_given, to record whether it is a given or wanted binding. Some consequential chagnes to creating an evidence binding (so that we record whether it is given or wanted). * AbsBinds field abs_ev_binds is now a *list* of TcEvBiinds; see Note [Typechecking plan for instance declarations] in TcInstDcls * Some significant changes to the type checking of instance declarations; Note [Typechecking plan for instance declarations] in TcInstDcls. * I found that TcErrors.relevantBindings was failing to zonk the origin of the constraint it was looking at, and hence failing to find some relevant bindings. Easy to fix, and orthogonal to everything else, but hard to disentangle. Some minor refactorig: * TcMType.newSimpleWanteds moves to Inst, renamed as newWanteds * TcClassDcl and TcInstDcls now have their own code for typechecking a method body, rather than sharing a single function. The shared function (ws TcClassDcl.tcInstanceMethodBody) didn't have much code and the differences were growing confusing. * Add new function TcRnMonad.pushLevelAndCaptureConstraints, and use it * Add new function Bag.catBagMaybes, and use it in TcSimplify --- testsuite/tests/perf/compiler/T3064.hs | 2 ++ testsuite/tests/perf/compiler/T5030.hs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'testsuite/tests/perf') diff --git a/testsuite/tests/perf/compiler/T3064.hs b/testsuite/tests/perf/compiler/T3064.hs index 39a51de8b0..53a87b599b 100644 --- a/testsuite/tests/perf/compiler/T3064.hs +++ b/testsuite/tests/perf/compiler/T3064.hs @@ -1,5 +1,7 @@ +{-# OPTIONS_GHC -fno-warn-redundant-constraints #-} {-# LANGUAGE Rank2Types, TypeSynonymInstances, FlexibleInstances #-} {-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving #-} + module T3064 where import Control.Applicative diff --git a/testsuite/tests/perf/compiler/T5030.hs b/testsuite/tests/perf/compiler/T5030.hs index b65e9cdd3c..6bb7478b50 100644 --- a/testsuite/tests/perf/compiler/T5030.hs +++ b/testsuite/tests/perf/compiler/T5030.hs @@ -134,15 +134,15 @@ data Operation cpu resultSize where type CDM cpu a = IO a -($=) :: CPU cpu => Var cpu size -> Operation cpu size -> CDM cpu () +($=) :: Var cpu size -> Operation cpu size -> CDM cpu () var $= op = undefined -tempVar :: CPU cpu => CDM cpu (Var cpu size) +tempVar :: CDM cpu (Var cpu size) tempVar = do cnt <- liftM fst undefined return $ Temp cnt -op :: CPU cpu => Operation cpu size -> CDM cpu (Var cpu size) +op :: Operation cpu size -> CDM cpu (Var cpu size) op operation = do v <- tempVar v $= operation -- cgit v1.2.1