Fine-Grained Unused Warnings (#42)

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.

I'm supportive of this proposal in general -- that is, make it easy to find
what the "root" unused bindings are, without cluttering up the warnings
with all the transitively unused ones.
But I have a question (added on the discussion thread) about the ergonomics.
On Fri, 8 Sept 2023 at 03:16, Chris Dornan
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.
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

I’m supportive of this proposal. I think Adam raised a good concern on the discussion with respect to tooling. As this does not impact GHCs acceptance of existing code, I’m more lenient towards these changes. Moritz On Sat, 9 Sep 2023 at 5:43 AM, Simon Peyton Jones < simon.peytonjones@gmail.com> wrote:
I'm supportive of this proposal in general -- that is, make it easy to find what the "root" unused bindings are, without cluttering up the warnings with all the transitively unused ones.
But I have a question (added on the discussion thread) about the ergonomics.
On Fri, 8 Sept 2023 at 03:16, Chris Dornan
wrote: 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.
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

Thanks Simon, Moritz and Adam, I asked Jakob to address Simon's and Tom's suggestions, at least to explain why they don't feature in the current draft. I have also made it clear we need some downstream tooling input. Personally, I still like the proposal in the current draft and am hoping Jakob will see a way to resolve the points raised by Tom and Simon without too much disruption. Chris
On 9 Sep 2023, at 03:12, Moritz Angermann
wrote: I’m supportive of this proposal. I think Adam raised a good concern on the discussion with respect to tooling. As this does not impact GHCs acceptance of existing code, I’m more lenient towards these changes.
Moritz
On Sat, 9 Sep 2023 at 5:43 AM, Simon Peyton Jones
mailto:simon.peytonjones@gmail.com> wrote: I'm supportive of this proposal in general -- that is, make it easy to find what the "root" unused bindings are, without cluttering up the warnings with all the transitively unused ones.
But I have a question (added on the discussion thread) about the ergonomics.
On Fri, 8 Sept 2023 at 03:16, Chris Dornan
mailto:chris@chrisdornan.com> wrote: 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.
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org mailto:ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
ghc-steering-committee mailing list ghc-steering-committee@haskell.org mailto:ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee

I mentioned on the github thread that I think this will impact some tooling
(the emacs mode in particular). I do think that moving away from the simple
format of each error/warning having a separate source range in an
easy-to-parse format is not something we should do lightly. That's useful
both for humans and computers, I would argue.
On Fri, 8 Sept 2023 at 03:16, Chris Dornan
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.
_______________________________________________ ghc-steering-committee mailing list ghc-steering-committee@haskell.org https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
participants (4)
-
Chris Dornan
-
Moritz Angermann
-
Simon Marlow
-
Simon Peyton Jones