[commit: ghc] master: Comments about -Wredundant-constraints (3174beb)

git at git.haskell.org git at git.haskell.org
Mon Oct 17 07:42:25 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/3174beb68919bf706ae5ec7d7d58d11759ba3584/ghc

>---------------------------------------------------------------

commit 3174beb68919bf706ae5ec7d7d58d11759ba3584
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Oct 14 10:41:14 2016 +0100

    Comments about -Wredundant-constraints


>---------------------------------------------------------------

3174beb68919bf706ae5ec7d7d58d11759ba3584
 compiler/typecheck/TcErrors.hs   |  1 +
 compiler/typecheck/TcSimplify.hs | 24 +++++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs
index d49ca64..4837f52 100644
--- a/compiler/typecheck/TcErrors.hs
+++ b/compiler/typecheck/TcErrors.hs
@@ -367,6 +367,7 @@ reportImplic ctxt implic@(Implic { ic_skols = tvs, ic_given = given
                     _                             -> []
 
 warnRedundantConstraints :: ReportErrCtxt -> TcLclEnv -> SkolemInfo -> [EvVar] -> TcM ()
+-- See Note [Tracking redundant constraints] in TcSimplify
 warnRedundantConstraints ctxt env info ev_vars
  | null redundant_evs
  = return ()
diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs
index 39b2d83..d146c73 100644
--- a/compiler/typecheck/TcSimplify.hs
+++ b/compiler/typecheck/TcSimplify.hs
@@ -1511,13 +1511,23 @@ works:
 
 ----- Shortcomings
 
-Consider (see Trac #9939)
-    f2 :: (Eq a, Ord a) => a -> a -> Bool
-    -- Ord a redundant, but Eq a is reported
-    f2 x y = (x == y)
-
-We report (Eq a) as redundant, whereas actually (Ord a) is.  But it's
-really not easy to detect that!
+After I introduced -Wredundant-constraints there was extensive discussion
+about cases where it reported a redundant constraint but the programmer
+really wanted it.  See
+
+  * #11370 (removed it from -Wdefault)
+  * #10635 (removed it from -Wall as well)
+  * #12142
+  * #11474, #10100 (class not used, but its fundeps are)
+  * #11099 (redundant, but still desired)
+  * #10183 (constraint necessary to exclude omitted case)
+
+  * #9939:     f2 :: (Eq a, Ord a) => a -> a -> Bool
+               -- Ord a redundant, but Eq a is reported
+              f2 x y = (x == y)
+
+    We report (Eq a) as redundant, whereas actually (Ord a) is.
+    But it's really not easy to detect that!
 
 
 Note [Cutting off simpl_loop]



More information about the ghc-commits mailing list