ghc-mod icon indicating copy to clipboard operation
ghc-mod copied to clipboard

Integrate dead-code-detection (whole project usage analysis)

Open DanielG opened this issue 10 years ago • 3 comments

https://github.com/soenkehahn/dead-code-detection

DanielG avatar Sep 24 '15 06:09 DanielG

Okay so GHC doesn't do cross module usage analysis apparently. So say you have some modules:

module Main where

import A

main = print foo
foo = bar
module A where

bar = 123
baz = 456

then ghc will not complain about baz but dead-code-detection will.

I'm not sure how/if this would work with libraries but I think give than we have knowledge of all components in Cabal package we could extend this thing to do cross component usage analysis too!

I.e. if a library defines and exports something but no other component in the package uses it. This doesn't really make sense as something you complain about all the time but it's a sort of nice-to-have for library writers to check manually for any dead code they may simply have forgotten about.

DanielG avatar Sep 25 '15 06:09 DanielG

I think the person initiating dead-code checks will have to somehow define the unit of compilation to be checked. Or maybe even a set of things being compiled.

alanz avatar Sep 25 '15 06:09 alanz

Agreed

DanielG avatar Sep 25 '15 06:09 DanielG