Looking for unused Haskell functions in a module or file?

Is there a way to automatically find unused functions (and constants) in a module or .hs file? In particular, I mean those functions that are not used (directly or indirectly) by functions in the export list of the current module / file.

I know that, for example, Emacs haskell mode has the ability to warn about unused import as follows: The import of XXX is redundant

Is there a similar tool or method for finding unused functions?

Note. I know that this can be done manually by deleting some code and seeing if it all compiles. But this is a tedious process.

+5
source share
1 answer

Here are some relevant ghc -W flags:

 -Wunused-binds -Wunused-do-bind -Wunused-foralls -Wunused-imports -Wunused-local-binds -Wunused-matches -Wunused-pattern-binds -Wunused-top-binds -Wunused-type-patterns 

Or just use -Wall . You can get a complete list of ghc flags with ghc --show-options .

+6
source

Source: https://habr.com/ru/post/1270638/


All Articles