
Proposal: Fine-Grained Unused Warnings (#42) Author: Jakob Brünker Rendered proposal: https://github.com/JakobBruenker/ghc-proposals/blob/fine-grained-unused/prop... Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/434 Recommendation: Acceptance ## Summary GHC currently warns equally about any superfluous binding that it discovers, regardless of whether the definition is unreferenced anywhere itself, or is merely mentioned by other definitions that are similarly superfluous. The proposal proposes to replace these warnings with just the warnings about definitions that are not referenced anywhere, but list within those warnings the entities it references that would otherwise not be required. The same information is being conveyed under this proposal as previously, but in a more structured manner. The proposal is careful to ensure the -Wunused-* controls (-Wunused-top-binds, etc.) are respected, so the subwarnings of transitively unused entities are only listed if their corresponding -Wunused-* control is active. As Jakob points out in the proposal, getting these warnings into some structure is partly motivated by IDE usage where the 'additional [transitive] warnings take up a lot of valuable screen real estate'. ## Example [From the proposal] In the following code, module Foo () import Data.List as L foo = L.intercalate `intercalate` is transitively unused, since it is only used by `foo`, which is unused. The warning that's produced will be Foo.hs:5:1: warning: [-Wunused-top-binds] Defined but not used: ‘foo’ as a consequence the following imports are transitively unused [-Wunused-imports]: Data.List imported at foo.hs:3:1: The warning about transitively unused bindings only appears if both the warning flag for the unused binding (in this case -Wunused-top-binds) and the the one for the transitively unused binding itself (in this case -Wunused-imports) are enabled. ## Recommendation This proposal is not at all disruptive (arguably to the extent of not requiring a GHC proposal review), is well thought out, and can improve the GHC/IDE UI so I recommend that we accept it.