Skip to content

Commit

Permalink
[ fix haskell#7251 ] sort and nub module list inferred by cabal init …
Browse files Browse the repository at this point in the history
…--lib

This should fix the problem that duplicate entries end up in
exposed-modules, e.g. from Foo.x and Foo.hs (with alex as build-tool).
  • Loading branch information
andreasabel committed Jan 19, 2021
1 parent d60a060 commit cd73e4d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cabal-install/src/Distribution/Client/Init/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import System.FilePath

import qualified Data.List.NonEmpty as NE
import qualified Data.Map as M
import qualified Data.Set as Set

import Control.Monad
( (>=>) )
import Control.Arrow
Expand Down Expand Up @@ -595,7 +597,7 @@ getModulesBuildToolsAndDeps pkgIx flags = do
let sourceFiles = filter (isSourceFile (sourceDirs flags)) sourceFiles0

Just mods <- return (exposedModules flags)
?>> (return . Just . map moduleName $ sourceFiles)
?>> (return . Just . sortNub . map moduleName $ sourceFiles)

tools <- return (buildTools flags)
?>> (return . Just . neededBuildPrograms $ sourceFiles)
Expand Down Expand Up @@ -645,6 +647,10 @@ getModulesBuildToolsAndDeps pkgIx flags = do
, otherExts = exts
}

where
sortNub :: Ord a => [a] -> [a]
sortNub = Set.toList . Set.fromList

-- | Given a list of imported modules, retrieve the list of dependencies that
-- provide those modules.
importsToDeps :: InitFlags -> [ModuleName] -> InstalledPackageIndex -> IO [P.Dependency]
Expand Down

0 comments on commit cd73e4d

Please sign in to comment.