[Haskell-cafe] Cabal: other-modules necessary?

Tom Ellis tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Sun Sep 18 16:47:11 UTC 2022


Ah, that's interesting Oleg, thanks.  I like the idea of Cabal being
able to specify the exact mapping between modules and source files.

Tom

On Fri, Sep 16, 2022 at 04:05:53PM +0300, Oleg Grenrus wrote:
> That is error generated by GHC.
> 
> The culprit is `ghc --make` mode which discovers modules/files on its own.
> 
> If there were a way to say (for Cabal to GHC) that use these files to
> compile the component, and fail otherwise, then -Wmissing-home-modules
> would turn into error.
> 
> In fact, it would be great if it where possible to say that *this*
> module is in *that* file, something like `MyFoo:src/MyFoo.hs`.
> 
> That would also solve a problem of having same hs-source-dirs for
> different components, as Cabal would be able to tell GHC that "don't
> look for this modules locally, use dependencies". As currently GHC will
> eagerly look for modules locally first. Always.
> 
> - Oleg
> 
> On 16.9.2022 12.23, Tom Ellis wrote:
> > On Fri, Sep 16, 2022 at 10:47:47AM +0200, Volker Wysk wrote:
> >> The cabal user guide says (in section 6.2.12): "Every module in the package
> >> must be listed in one of other-modules, library:exposed-modules or
> >> executable:main-is fields."
> >>
> >> However, I only get a warning message, when I comment out the other-modules
> >> field in my .cabal file. The program compiles. This is the message:
> >>
> >> <no location info>: warning: [-Wmissing-home-modules]
> >>     These modules are needed for compilation but not listed in your .cabalĀ 
> >>     file's other-modules: 
> >>         Hsskripte Sicherung SicherungAktionen Text Wahl Zeit
> >>
> >> Is it really necessary to specify all the imported modules? If so, why does
> >> the program compile? Can that warning message be turned off?
> > In response to all the sibling replies at once, is there a good reason
> > for this behaviour?  Succeeding but then failing later with obscure
> > errors (once the original warning message is nowhere to be seen) seems
> > like the worst of all worlds.  Suppose cabal errored here and failed
> > to proceed.  What would be the downside of that (besides backward
> > incompatibility)?


More information about the Haskell-Cafe mailing list