Skip to content

Mode for ghc --make which only compiles the files I pass on command line

Here are a few situations where GHC picks up "too many" files when running --make:

  • Suppose a user doesn't add enough modules to exposed-modules/other-modules in Cabal. GHC will happily pick up extra source files, but those files won't get bundled in the sdist or be included in ABI computation. Difficult for Cabal to tell when this has happened.
  • Suppose the user wants to define multiple internal libraries, and give them the same hs-source-dir. This won't work: because GHC sees the source file it will prefer it over the external dependency.

There's a very easy thing that GHC could do to make this better: add a mode to --make which says "only compile the files that are explicitly passed on the command line." Something like ghc --make --only A.hs will only build A.hs, and error if you try to import B.hs.

Seems like this should be fairly easy to do, and would help solve a lot of problems related to GHC slurping up too many files.

(I've assigned myself because this is a blocker for backpack, but if someone wants to take a crack at this be my guest.)

Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC dcoutts
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information