Make it clear when an unused binds warning is due to transitive unuse
Motivation
a :: Int
a = 4
where bar = foo
foo = 3
Given this file, with -Wunused-local-binds
, GHC will output a warning saying that bar
is unused, and a warning saying that foo
is unused.
Every once in a while I find myself confused by this, thinking "I'm sure I used foo
somewhere", until I remember that GHC warns about transitively unused bindings since version 6.0.
Proposal
Instead of saying "Defined but not used: foo
", GHC should say something like "Defined but only used in unused bindings: foo
".
Furthermore, ideally, the warning could be split into two warnings, -Wunused-local-binds
to take care of genuinely unused bindings like bar
, and -Wonly-in-unused-local-binds
(or a better name) to take care of bindings like foo
. This would allow users who wish to declutter the warning output to disable the latter warning.
To keep the warning behavior consistent with the current warning, -Wunused-local-binds
could imply -Wonly-in-unused-local-binds
.
Unresolved Questions
Would splitting the warning (even if the new warning is implied by the old warning) require a proper GHC proposal?