haskell/cabal — pull request #1455 by sebastiaanvisser (2013-08-31 16:00:46+00:00)
Title: Warn about used unlisted modules

Two small contributions:

1. Invoke GHC using the -M flag to create a makefile containing module dependencies. The simple makefile format is parsed into a ModuleHierarchy datatype which is (for now) a simple mapping from modules to their dependencies.

2. Diff the module dependencies fetched from GHC with the modules listed in the `.cabal` file. For all unlisted module we produce a warning so users are encouraged to add the modules.

Currently the module dependencies are not stored anywhere, however this might be a useful thing to do in the future if more parts of the build process require it.

GHC might fail on the -M flag in the case of cyclic dependencies. I don't want to disallow building programs with cyclic dependencies so we catch all errors in warn in the case of failure. Of course, we do continue the normal build process.

Let me know if anything is missing or things could be clearer. Thanks!