[ghc-steering-committee] Fine-Grained Unused Warnings (#42)

Chris Dornan chris at chrisdornan.com
Fri Sep 8 10:15:52 UTC 2023


Proposal: Fine-Grained Unused Warnings (#42)
Author: Jakob Brünker
Rendered proposal:
https://github.com/JakobBruenker/ghc-proposals/blob/fine-grained-unused/proposals/0000-fine-grained-unused-warnings.rst
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20230908/68234efa/attachment.html>


More information about the ghc-steering-committee mailing list