Cabal: other-modules necessary?

Hi 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? Apart from that, I'm happy with cabal. :-) Cheers, Volker

Hello Volker, Compilation will, indeed, succeed. However, distribution won't: if the module is not listed in `Other-Modules` (or any of the other sections), it won't be included in the tarball generated when you invoke `cabal sdist`, i.e., the source archive uploaded to Hackage. Hence, if someone then tries to download and build your package from Hackage, this will fail, since some module source files are missing. There may be other effects of not listing some module, though above is the one I'm aware of. Cheers, Nicolas On Fri, 2022-09-16 at 10:47 +0200, Volker Wysk wrote:
Hi
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?
Apart from that, I'm happy with cabal. :-)
Cheers, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Am Freitag, dem 16.09.2022 um 10:53 +0200 schrieb Nicolas Trangez:
Hello Volker,
Compilation will, indeed, succeed. However, distribution won't: if the module is not listed in `Other-Modules` (or any of the other sections), it won't be included in the tarball generated when you invoke `cabal sdist`, i.e., the source archive uploaded to Hackage.
That's fine im my case. I don't want to distribute that. Regarding my other question (Can that warning message be turned off?), I've found out. It can be turned off with this line in the cabal.project file: Wmissing-home-modules: False Regards, Volker
Hence, if someone then tries to download and build your package from Hackage, this will fail, since some module source files are missing.
There may be other effects of not listing some module, though above is the one I'm aware of.
Cheers,
Nicolas
On Fri, 2022-09-16 at 10:47 +0200, Volker Wysk wrote:
Hi
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?
Apart from that, I'm happy with cabal. :-)
Cheers, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Am Freitag, dem 16.09.2022 um 11:10 +0200 schrieb Volker Wysk:
Regarding my other question (Can that warning message be turned off?), I've found out. It can be turned off with this line in the cabal.project file:
Wmissing-home-modules: False
Oh, I made a mistake. This DOESN'T work. Volker

Also even locally, when you depend on the library and try to link you'll get linker errors as omitted modules are not part of linkage. Write a test-suite for your library, and you'll notice! For example, if I comment out other-modules in postgresql-simple and try to run a test-suite named "test" cabal run test I'll get (just) a warning when compiling the library <no location info>: warning: [-Wmissing-home-modules] These modules are needed for compilation but not listed in your .cabal file's other-modules: Database.PostgreSQL.Simple.Compat Database.PostgreSQL.Simple.HStore.Implementation Database.PostgreSQL.Simple.Internal.PQResultUtils Database.PostgreSQL.Simple.Time.Implementation Database.PostgreSQL.Simple.Time.Internal.Parser Database.PostgreSQL.Simple.Time.Internal.Printer Database.PostgreSQL.Simple.TypeInfo.Types but compilation of test-suite fails (it uses TemplateHaskell, otherwise it probably would fail when linking the executable) <command line>: can't load .so/.DLL for: /code/public-haskell/postgresql-simple/dist-newstyle/build/x86_64-linux/ghc-8.6.5/postgresql-simple-0.6.4/build/libHSpostgresql-simple-0.6.4-inplace-ghc8.6.5.so (/code/public-haskell/postgresql-simple/dist-newstyle/build/x86_64-linux/ghc-8.6.5/postgresql-simple-0.6.4/build/libHSpostgresql-simple-0.6.4-inplace-ghc8.6.5.so: undefined symbol: postgresqlzmsimplezm0zi6zi4zminplace_DatabaseziPostgreSQLziSimpleziInternalziPQResultUtils_zdwfinishQueryWith_closure) What is additionally annoying, is that if your executable doesn't actually (even transitively) use any symbols from other-modules (which some test-suites may not), they won't be needed for linking and it will succeed... until you add something, and linking will fail with incomprehensible error like above. - Oleg On 16.9.2022 11.53, Nicolas Trangez wrote:
Hello Volker,
Compilation will, indeed, succeed. However, distribution won't: if the module is not listed in `Other-Modules` (or any of the other sections), it won't be included in the tarball generated when you invoke `cabal sdist`, i.e., the source archive uploaded to Hackage.
Hence, if someone then tries to download and build your package from Hackage, this will fail, since some module source files are missing.
There may be other effects of not listing some module, though above is the one I'm aware of.
Cheers,
Nicolas
On Fri, 2022-09-16 at 10:47 +0200, Volker Wysk wrote:
Hi
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?
Apart from that, I'm happy with cabal. :-)
Cheers, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Hi! Am Freitag, dem 16.09.2022 um 12:12 +0300 schrieb Oleg Grenrus:
Also even locally, when you depend on the library and try to link you'll get linker errors as omitted modules are not part of linkage.
Write a test-suite for your library, and you'll notice!
I'm not writing a library here, but several executables. And it works, without specifying "other-modules". But I guess you're right when a library is to be compiled. Bye, Volker
For example, if I comment out other-modules in postgresql-simple and try to run a test-suite named "test"
cabal run test
I'll get (just) a warning when compiling the library
<no location info>: warning: [-Wmissing-home-modules] These modules are needed for compilation but not listed in your .cabal file's other-modules: Database.PostgreSQL.Simple.Compat Database.PostgreSQL.Simple.HStore.Implementation Database.PostgreSQL.Simple.Internal.PQResultUtils Database.PostgreSQL.Simple.Time.Implementation Database.PostgreSQL.Simple.Time.Internal.Parser Database.PostgreSQL.Simple.Time.Internal.Printer Database.PostgreSQL.Simple.TypeInfo.Types
but compilation of test-suite fails (it uses TemplateHaskell, otherwise it probably would fail when linking the executable)
<command line>: can't load .so/.DLL for: /code/public-haskell/postgresql-simple/dist-newstyle/build/x86_64-linux/ghc-8.6.5/postgresql-simple-0.6.4/build/libHSpostgresql-simple-0.6.4-inplace-ghc8.6.5.so (/code/public-haskell/postgresql-simple/dist-newstyle/build/x86_64-linux/ghc-8.6.5/postgresql-simple-0.6.4/build/libHSpostgresql-simple-0.6.4-inplace-ghc8.6.5.so: undefined symbol: postgresqlzmsimplezm0zi6zi4zminplace_DatabaseziPostgreSQLziSimpleziInternalziPQResultUtils_zdwfinishQueryWith_closure)
What is additionally annoying, is that if your executable doesn't actually (even transitively) use any symbols from other-modules (which some test-suites may not), they won't be needed for linking and it will succeed... until you add something, and linking will fail with incomprehensible error like above.
- Oleg
On 16.9.2022 11.53, Nicolas Trangez wrote:
Hello Volker,
Compilation will, indeed, succeed. However, distribution won't: if the module is not listed in `Other-Modules` (or any of the other sections), it won't be included in the tarball generated when you invoke `cabal sdist`, i.e., the source archive uploaded to Hackage.
Hence, if someone then tries to download and build your package from Hackage, this will fail, since some module source files are missing.
There may be other effects of not listing some module, though above is the one I'm aware of.
Cheers,
Nicolas
On Fri, 2022-09-16 at 10:47 +0200, Volker Wysk wrote:
Hi
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?
Apart from that, I'm happy with cabal. :-)
Cheers, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Hi Volker, If you don't mention all modules in your Cabal file you may well get some very confusing linker errors later on when you build an executable, or try to use your library in another component. See https://stackoverflow.com/questions/28857275/cabal-test-fails-to-link-its-ow... for one such example of the very cryptic error you'll likely eventually run into! Ollie On Fri, 16 Sep 2022, at 9:47 AM, Volker Wysk wrote:
Hi
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?
Apart from that, I'm happy with cabal. :-)
Cheers, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Am Freitag, dem 16.09.2022 um 10:12 +0100 schrieb Oliver Charles:
Hi Volker,
If you don't mention all modules in your Cabal file you may well get some very confusing linker errors later on when you build an executable, or try to use your library in another component. See https://stackoverflow.com/questions/28857275/cabal-test-fails-to-link-its-ow... for one such example of the very cryptic error you'll likely eventually run into!
It works now, without other-modules. I don't have a library in my package, just executables. But I guess you're right. I'll rather add all the modules to the cabal file. It's just a little bothersome. Volker
Ollie
On Fri, 16 Sep 2022, at 9:47 AM, Volker Wysk wrote:
Hi
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?
Apart from that, I'm happy with cabal. :-)
Cheers, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

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)? Tom

Am Freitag, dem 16.09.2022 um 10:23 +0100 schrieb Tom Ellis:
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)?
I've already changed my mind. It's a little bothersome to manually add all the modules, which could be determined automatically. But it's better than having linker errors later. Regards, Volker

FWIW, You could use hpack (package.yaml) to automatically fill
exposed-module:
https://github.com/sol/hpack
In short, hpack is a YAML-encoded cabal format with some syntax sugars and
automatic module list generation.
Downside is that if you're using cabal-install as the package manager, you
should convert hpack to cabal each time you edit package.yaml or add new
modules (you could set up editor save hook and/or git pre-commit hook to
reduce such burden, though).
If you're using stack, however, stack will automatically generate .cabal
from package.yaml whenever it's needed, as hpack is integrated into stack.
2022年9月16日(金) 18:34 Volker Wysk
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
Am Freitag, dem 16.09.2022 um 10:23 +0100 schrieb Tom Ellis: 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)?
I've already changed my mind. It's a little bothersome to manually add all the modules, which could be determined automatically. But it's better than having linker errors later.
Regards, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Am Freitag, dem 16.09.2022 um 18:42 +0900 schrieb 石井大海:
FWIW, You could use hpack (package.yaml) to automatically fill exposed- module:
In short, hpack is a YAML-encoded cabal format with some syntax sugars and automatic module list generation. Downside is that if you're using cabal-install as the package manager, you should convert hpack to cabal each time you edit package.yaml or add new modules (you could set up editor save hook and/or git pre-commit hook to reduce such burden, though).
I've taken a look at this. It's somewhat complicated, even though it claims it doesn't "require the user to state the obvious, make sensible assumptions by default". There's no user manual. And the examples are quite verbose (again, even though it claims to be simple). I'll stick to cabal for now. At least until I know it better. Thanks for the hint. Volker
If you're using stack, however, stack will automatically generate .cabal from package.yaml whenever it's needed, as hpack is integrated into stack.
2022年9月16日(金) 18:34 Volker Wysk
: Am Freitag, dem 16.09.2022 um 10:23 +0100 schrieb Tom Ellis:
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)?
I've already changed my mind. It's a little bothersome to manually add all the modules, which could be determined automatically. But it's better than having linker errors later.
Regards, Volker _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Cabal doesn't know. GHC does, and is producing the
missing-home-modules warning. And even there, you're getting lucky; it
could miss one. Only the link step knows for certain what is missing,
because you would need whole-program compilation to reliably catch it
during the compile step.
On Fri, Sep 16, 2022 at 5:24 AM Tom Ellis
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)?
Tom _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- brandon s allbery kf8nh allbery.b@gmail.com
participants (7)
-
Brandon Allbery
-
Nicolas Trangez
-
Oleg Grenrus
-
Oliver Charles
-
Tom Ellis
-
Volker Wysk
-
石井大海