From 55ccc0a91c1fb388c4f78a29584c7190cae6838a Mon Sep 17 00:00:00 2001 From: Jaro Date: Mon, 2 Dec 2024 14:21:12 +0000 Subject: [PATCH] Explicit export lists for Main (#9890) * 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 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- cabal-install/src/Distribution/Client/Init/Defaults.hs | 4 ++-- changelog.d/pr-9890 | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelog.d/pr-9890 diff --git a/cabal-install/src/Distribution/Client/Init/Defaults.hs b/cabal-install/src/Distribution/Client/Init/Defaults.hs index a915a5159d3..3852bf835bf 100644 --- a/cabal-install/src/Distribution/Client/Init/Defaults.hs +++ b/cabal-install/src/Distribution/Client/Init/Defaults.hs @@ -165,7 +165,7 @@ myLibHs = myExeHs :: [String] myExeHs = - [ "module Main where" + [ "module Main (main) where" , "" , "main :: IO ()" , "main = putStrLn \"Hello, Haskell!\"" @@ -173,7 +173,7 @@ myExeHs = myLibExeHs :: [String] myLibExeHs = - [ "module Main where" + [ "module Main (main) where" , "" , "import qualified MyLib (someFunc)" , "" diff --git a/changelog.d/pr-9890 b/changelog.d/pr-9890 new file mode 100644 index 00000000000..e9861aed7af --- /dev/null +++ b/changelog.d/pr-9890 @@ -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. + +}