Improve warnings for rules that might not fire
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 24 Jul 2015 11:50:42 +0000 (12:50 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Mon, 27 Jul 2015 13:02:33 +0000 (14:02 +0100)
commit2d88a531b7e4dbf4016dca4b1ba3b5dc34256cf4
tree8a7819918d5a8e8fc69c3c036fb3c7670498cb84
parentbc4b64ca5b99bff6b3d5051b57cb2bc52bd4c841
Improve warnings for rules that might not fire

Two main things here

* Previously we only warned about the "head" function of the rule,
  but actually the warning applies to any free variable on the LHS.

* We now warn not only when one of these free vars can inline, but
  also if it has an active RULE (c.f. Trac #10528)

See Note [Rules and inlining/other rules] in Desugar

This actually shows up quite a few warnings in the libraries, notably
in Control.Arrow, where it correctly points out that rules like
    "compose/arr"   forall f g .
                    (arr f) . (arr g) = arr (f . g)
might never fire, because the rule for 'arr' (dictionary selection)
might fire first.  I'm not really sure what to do here; there is some
discussion in Trac #10595.

A minor change is adding BasicTypes.pprRuleName to pretty-print RuleName.
compiler/basicTypes/BasicTypes.hs
compiler/deSugar/Desugar.hs
compiler/iface/IfaceSyn.hs
compiler/iface/TcIface.hs
compiler/typecheck/TcRnTypes.hs
testsuite/tests/indexed-types/should_compile/Rules1.hs
testsuite/tests/indexed-types/should_compile/T2291.hs
testsuite/tests/simplCore/should_compile/T5776.hs
testsuite/tests/simplCore/should_compile/T6082-RULE.stderr
testsuite/tests/simplCore/should_compile/T7287.hs
testsuite/tests/typecheck/should_compile/tc111.hs