-
Notifications
You must be signed in to change notification settings - Fork 848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cabal's main-is
field (source file) does not alter GHC's -main-is
option (module and function name)
#6695
Comments
@andreasabel, how did you get it to build? I tried to reproduce with a spec-version: 0.36.0
name: test6695
version: 0.1.0.0
executables:
test6695:
main: Main.hs
source-dirs: app
dependencies:
- base generating Cabal file: cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.38.0.
--
-- see: https://github.com/sol/hpack
name: test6695
version: 0.1.0.0
license: BSD3
license-file: LICENSE
build-type: Simple
executable test6695
main-is: Main.hs
other-modules:
NoModuleName
hs-source-dirs:
app
build-depends:
base
default-language: Haskell2010 (In my package, I called and snapshot: lts-23.14 # GHC 9.8.4 However,
|
OK, so I can reproduce what you experienced, but only if the modules are in the project root directory. In my example, I had put them in an |
I think:
behaves as expected, namely:
|
Yes, so the question is how to communicate the |
@andreasabel, I may be wrong, but it seems to me that Cabal uses its That is, given
and not:
The Cabal User Guide has for
To force GHC to treat your cabal-version: 1.12
name: test6695
version: 0.1.0.0
build-type: Simple
executable test6695
main-is: Foo.hs
ghc-options: -main-is Foo -- Required because Foo.hs does not provide a `Main` module
build-depends:
base
default-language: Haskell2010 EDIT: So I think the resolution of this is more complete documentation in the Cabal User Guide. |
Your analysis is correct and matches my observation.
Yes, this is what I could extract from cabal's
Cabal aims to be build-tool with a declarative package language, in the spirit of the declarative functional language Haskell. So I am expecting a more declarative treatment of So, if I write I think this is correct behavior is hampered at the moment only by the extra effort this would cause. The build tool would have to extract the module name of FILE and communicate this to GHC via I see only two principled solutions here:
|
@andreasabel, I've opened a Cabal issue which treats this a gap in the documentation: but I understand your view that Cabal could also do something differently. I think that is best put directly to the Cabal project at its repository. |
main-is
is picked as main modulemain-is
field (source file) does not alter GHC's -main-is
option (module and function name)
If the module in
main-is
has a name and there is another module that has no explicit name (nomodule
header), then the other module is picked as main module.Bar.hs
Foo.hs
wrong-main.cabal
Packaged reproducer: wrong-main.tgz
The wrong result can be reproduced with this vanilla GHC call:
The correct result can be obtained by adding
-main-is Foo
:I suppose the difficulty is to extract the module name
Foo
fromFoo.hs
, since-main-is
does not accept a file, just a qualified (module) name.This issue is shared with cabal:
main-is
is picked as main module haskell/cabal#10832The text was updated successfully, but these errors were encountered: