Dead code and/or how to generate a cross reference from Haskell source

I don’t know of such a tool, so in the past I have done a bit of a hack instead.

If you have a comprehensive test suite, you can run it with GHC’s code coverage tracing enabled. Compile with -fhpc and use hpc markup to generate annotated source. This gives you the union of unused code and untested code, both of which you would probably like to address anyway.

SourceGraph can give you a bunch of information which you may also find useful.


There is now a tool for this very purpose: https://hackage.haskell.org/package/weeder

It's been around since 2017, and while it has limitations, it definitely helps with large codebases.