Skip to content
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 init does not always generate explicit export lists #9889

Open
noughtmare opened this issue Apr 14, 2024 · 4 comments · May be fixed by #9890
Open

cabal init does not always generate explicit export lists #9889

noughtmare opened this issue Apr 14, 2024 · 4 comments · May be fixed by #9890

Comments

@noughtmare
Copy link
Collaborator

Describe the bug

cabal init does not always generate explicit export lists. Export lists can be important for performance. Especially the Main module should always have an explicit export list that just exports the main function.

To Reproduce
Steps to reproduce the behavior:

$ cabal init -mnq --exe

(--libandexe has the same problem)

That generates:

module Main where

main :: IO ()
main = putStrLn "Hello, Haskell"

Expected behavior

It should generate:

module Main (main) where

main :: IO ()
main = putStrLn "Hello, Haskell"

System information

  • NixOS 24.05pre606852.fd281bd6b7d3 (Uakari)
  • cabal-install version 3.10.2.1
  • compiled using version 3.10.1.0 of the Cabal library
  • The Glorious Glasgow Haskell Compilation System, version 9.6.4
@ulysses4ever
Copy link
Collaborator

Hello and thanks for reporting! Not sure if it's useful to have the export list in Main specifically. But I guess if there's energy to fix it, that would be fine.

@noughtmare
Copy link
Collaborator Author

noughtmare commented Apr 14, 2024

Not sure if it's useful to have the export list in Main specifically.

It is especially important to add an export list to the main module, because it only has to export main and GHC can do more aggressive optimizations on all the other non-exported functions.

I still think omission of the explicit export list on the main module is a performance bug.

@geekosaur
Copy link
Collaborator

This is the wrong thing to do if Main exports other functions, and assuming every Haskell programmer uses HLS is not appropriate.

@noughtmare
Copy link
Collaborator Author

Is it even possible to import the Main module in another module? Even if that is possible, I think we can agree that 99% of packages don't do that. So I don't see the harm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants