@@ -4,24 +4,24 @@ module Main
4
4
5
5
import Data.List ( nub , sortOn )
6
6
import Distribution.InstalledPackageInfo
7
- ( sourcePackageId , installedUnitId )
8
- import Distribution.Package ( UnitId , packageVersion , packageName )
7
+ ( installedUnitId , sourcePackageId )
8
+ import Distribution.Package ( UnitId , packageName , packageVersion )
9
9
import Distribution.PackageDescription
10
- ( PackageDescription (), Executable (.. ) )
10
+ ( Executable (.. ), PackageDescription )
11
11
import Distribution.Pretty ( prettyShow )
12
12
import Distribution.Simple
13
- ( defaultMainWithHooks , UserHooks (.. ), simpleUserHooks )
13
+ ( UserHooks (.. ), defaultMainWithHooks , simpleUserHooks )
14
14
import Distribution.Simple.BuildPaths ( autogenPackageModulesDir )
15
15
import Distribution.Simple.LocalBuildInfo
16
- ( installedPkgs , withLibLBI , withExeLBI , LocalBuildInfo ()
17
- , ComponentLocalBuildInfo ( componentPackageDeps )
16
+ ( ComponentLocalBuildInfo ( .. ), LocalBuildInfo , installedPkgs
17
+ , withExeLBI , withLibLBI
18
18
)
19
19
import Distribution.Simple.PackageIndex
20
20
( allPackages , dependencyClosure )
21
21
import Distribution.Simple.Setup
22
22
( BuildFlags (.. ), ReplFlags (.. ), fromFlag )
23
23
import Distribution.Simple.Utils
24
- ( rewriteFileEx , createDirectoryIfMissingVerbose )
24
+ ( createDirectoryIfMissingVerbose , rewriteFileEx )
25
25
import Distribution.Types.PackageName ( unPackageName )
26
26
import Distribution.Types.UnqualComponentName
27
27
( unUnqualComponentName )
@@ -41,7 +41,11 @@ main = defaultMainWithHooks simpleUserHooks
41
41
replHook simpleUserHooks pkg lbi hooks flags args
42
42
}
43
43
44
- generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
44
+ generateBuildModule ::
45
+ Verbosity
46
+ -> PackageDescription
47
+ -> LocalBuildInfo
48
+ -> IO ()
45
49
generateBuildModule verbosity pkg lbi = do
46
50
let dir = autogenPackageModulesDir lbi
47
51
createDirectoryIfMissingVerbose verbosity True dir
@@ -60,17 +64,22 @@ generateBuildModule verbosity pkg lbi = do
60
64
formatdeps = map formatone . sortOn unPackageName'
61
65
formatone p = unPackageName' p ++ " -" ++ prettyShow (packageVersion p)
62
66
unPackageName' = unPackageName . packageName
63
- transDeps xs ys =
64
- either (map sourcePackageId . allPackages) handleDepClosureFailure $ dependencyClosure allInstPkgsIdx availInstPkgIds
65
- where
66
- allInstPkgsIdx = installedPkgs lbi
67
- allInstPkgIds = map installedUnitId $ allPackages allInstPkgsIdx
68
- -- instPkgIds includes `stack-X.X.X`, which is not a dependency hence is missing from allInstPkgsIdx. Filter that out.
69
- availInstPkgIds = filter (`elem` allInstPkgIds) $ testDeps xs ys
70
- handleDepClosureFailure unsatisfied =
71
- error $
72
- " Computation of transitive dependencies failed." ++
73
- if null unsatisfied then " " else " Unresolved dependencies: " ++ show unsatisfied
67
+ transDeps xs ys = either
68
+ (map sourcePackageId . allPackages)
69
+ handleDepClosureFailure $ dependencyClosure allInstPkgsIdx availInstPkgIds
70
+ where
71
+ allInstPkgsIdx = installedPkgs lbi
72
+ allInstPkgIds = map installedUnitId $ allPackages allInstPkgsIdx
73
+ -- instPkgIds includes `stack-X.X.X`, which is not a dependency hence is
74
+ -- missing from allInstPkgsIdx. Filter that out.
75
+ availInstPkgIds = filter (`elem` allInstPkgIds) $ testDeps xs ys
76
+ handleDepClosureFailure unsatisfied =
77
+ error $
78
+ " Computation of transitive dependencies failed."
79
+ ++ if null unsatisfied
80
+ then " "
81
+ else " Unresolved dependencies: " ++ show unsatisfied
74
82
75
83
testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [UnitId ]
76
- testDeps xs ys = map fst $ nub $ componentPackageDeps xs ++ componentPackageDeps ys
84
+ testDeps xs ys =
85
+ map fst $ nub $ componentPackageDeps xs ++ componentPackageDeps ys
0 commit comments