Skip to content

Commit

Permalink
Explicit export lists for Main (#9890)
Browse files Browse the repository at this point in the history
* Explicit export lists for Main

Lack of explicit export list can degrade performance. The Main module in particular should always have an explicit export list that contains just the main function.

* add changelog

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent da40ea6 commit 55ccc0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cabal-install/src/Distribution/Client/Init/Defaults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ myLibHs =

myExeHs :: [String]
myExeHs =
[ "module Main where"
[ "module Main (main) where"
, ""
, "main :: IO ()"
, "main = putStrLn \"Hello, Haskell!\""
]

myLibExeHs :: [String]
myLibExeHs =
[ "module Main where"
[ "module Main (main) where"
, ""
, "import qualified MyLib (someFunc)"
, ""
Expand Down
10 changes: 10 additions & 0 deletions changelog.d/pr-9890
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
synopsis: `cabal init` generates explicit export lists for Main
packages: cabal-install
prs: #9890
issues: #9889

description: {

- Lack of explicit export list can degrade performance. The `Main` module in particular should always have an explicit export list that contains just the main function. Then, the compiler can do more aggressive optimizations on all the other non-exported functions.

}

0 comments on commit 55ccc0a

Please sign in to comment.