aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-08-07 19:04:12 +0200
committerDaniel Gröber (dxld) <dxld@darkboxed.org>2019-09-17 17:48:26 +0200
commit9cb1c594fa944bdaba84de69e35118430b5590cf (patch)
treeec2ef74370ad6640caf9b3afd9d57b8e63acc777
parentaad828c48f26ea6febaabf37632b0e45868db895 (diff)
Break cycle between 'Package' and 'Unit'
-rw-r--r--lib/Distribution/Helper.hs2
-rw-r--r--src/CabalHelper/Compiletime/Program/CabalInstall.hs4
-rw-r--r--src/CabalHelper/Compiletime/Program/Stack.hs2
-rw-r--r--src/CabalHelper/Compiletime/Types.hs8
4 files changed, 10 insertions, 6 deletions
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs
index eb277d5..79c9d57 100644
--- a/lib/Distribution/Helper.hs
+++ b/lib/Distribution/Helper.hs
@@ -493,7 +493,7 @@ readProjInfo qe pc pcm = withVerbosity $ do
, pFlags = []
, pUnits = (:|[]) Unit
{ uUnitId = UnitId pkg_name
- , uPackage = pkg
+ , uPackage = pkg { pUnits = () }
, uDistDir = DistDirLib distdir
, uImpl = UnitImplV1
}
diff --git a/src/CabalHelper/Compiletime/Program/CabalInstall.hs b/src/CabalHelper/Compiletime/Program/CabalInstall.hs
index cce4364..cc05421 100644
--- a/src/CabalHelper/Compiletime/Program/CabalInstall.hs
+++ b/src/CabalHelper/Compiletime/Program/CabalInstall.hs
@@ -262,6 +262,7 @@ planPackages plan = do
where
groupByMap = Map.fromListWith (<>) . map (CP.uPId &&& (:|[]))
+ mkPackage :: NonEmpty CP.Unit -> IO (Package ('Cabal 'CV2))
mkPackage units@(unit :| _) =
case unit of
CP.Unit
@@ -275,11 +276,12 @@ planPackages plan = do
, pSourceDir = pkgdir
, pCabalFile = CabalFile cabal_file
, pFlags = []
- , pUnits = fmap (mkUnit pkg) units
+ , pUnits = fmap (mkUnit pkg { pUnits = () }) units
}
return pkg
_ -> panicIO "planPackages.mkPackage: Got non-unpacked package src!"
+ mkUnit :: Package' () -> CP.Unit -> Unit ('Cabal 'CV2)
mkUnit pkg CP.Unit
{ uDistDir=Just distdirv1
, uComps=comps
diff --git a/src/CabalHelper/Compiletime/Program/Stack.hs b/src/CabalHelper/Compiletime/Program/Stack.hs
index 6f3365f..5c5f808 100644
--- a/src/CabalHelper/Compiletime/Program/Stack.hs
+++ b/src/CabalHelper/Compiletime/Program/Stack.hs
@@ -60,7 +60,7 @@ getPackage qe cabal_file@(CabalFile cabal_file_path) = do
, pUnits = (:|[]) $ Unit
{ uUnitId = UnitId pkg_name
, uDistDir = DistDirLib $ pkgdir </> distdirv1_rel
- , uPackage = pkg
+ , uPackage = pkg { pUnits = () }
, uImpl = UnitImplStack
}
}
diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs
index d206cf0..44849f5 100644
--- a/src/CabalHelper/Compiletime/Types.hs
+++ b/src/CabalHelper/Compiletime/Types.hs
@@ -279,14 +279,16 @@ data QueryCache pt = QueryCache
newtype DistDirLib = DistDirLib FilePath
deriving (Eq, Ord, Read, Show)
+type Package pt = Package' (NonEmpty (Unit pt))
+
-- | A 'Package' is a named collection of many 'Unit's.
-data Package pt = Package
+data Package' units = Package
{ pPackageName :: !String
, pSourceDir :: !FilePath
, pCabalFile :: !CabalFile
, pFlags :: ![(String, Bool)]
-- | Cabal flags to set when configuring and building this package.
- , pUnits :: !(NonEmpty (Unit pt))
+ , pUnits :: !units
} deriving (Show)
-- | A 'Unit' is essentially a "build target". It is used to refer to a set
@@ -303,7 +305,7 @@ data Package pt = Package
-- was created in. However this is not enforced by the API.
data Unit pt = Unit
{ uUnitId :: !UnitId
- , uPackage :: !(Package pt)
+ , uPackage :: !(Package' ())
, uDistDir :: !DistDirLib
, uImpl :: !(UnitImpl pt)
} deriving (Show)