Skip to content

Commit

Permalink
Split resolvePackage into two functions.
Browse files Browse the repository at this point in the history
The gruntwork is now done by `packageFromPackageDescription`. The idea
is that if you already have a resolved `GenericPackageDescription`,
i.e. a `PackageDescription`, then you should still be able to get
a `Package` out of it.
  • Loading branch information
mboes committed Jun 4, 2016
1 parent 3103ebe commit ba35daa
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Stack/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Stack.Package
,readPackageUnresolved
,readPackageUnresolvedBS
,resolvePackage
,packageFromPackageDescription
,findOrGenerateCabalFile
,hpack
,Package(..)
Expand Down Expand Up @@ -179,6 +180,16 @@ resolvePackage :: PackageConfig
-> GenericPackageDescription
-> Package
resolvePackage packageConfig gpkg =
packageFromPackageDescription
packageConfig
gpkg
(resolvePackageDescription packageConfig gpkg)

packageFromPackageDescription :: PackageConfig
-> GenericPackageDescription
-> PackageDescription
-> Package
packageFromPackageDescription packageConfig gpkg pkg =
Package
{ packageName = name
, packageVersion = fromCabalVersion (pkgVersion pkgId)
Expand Down Expand Up @@ -210,7 +221,7 @@ resolvePackage packageConfig gpkg =
False
(not . null . exposedModules)
(library pkg)
, packageSimpleType = buildType (packageDescription gpkg) == Just Simple
, packageSimpleType = buildType pkg == Just Simple
}
where
pkgFiles = GetPackageFiles $
Expand All @@ -236,9 +247,8 @@ resolvePackage packageConfig gpkg =
hpackExists <- doesFileExist hpackPath
return $ if hpackExists then S.singleton hpackPath else S.empty
return (componentModules, componentFiles, buildFiles <> dataFiles', warnings)
pkgId = package (packageDescription gpkg)
pkgId = package pkg
name = fromCabalPackageName (pkgName pkgId)
pkg = resolvePackageDescription packageConfig gpkg
deps = M.filterWithKey (const . (/= name)) (packageDependencies pkg)

-- | Generate GHC options for the package's components, and a list of
Expand Down

0 comments on commit ba35daa

Please sign in to comment.