@@ -43,6 +43,7 @@ import Stack.Types.Compiler
43
43
import Stack.Types.Config
44
44
import Stack.Types.GhcPkgId
45
45
import Stack.Types.NamedComponent
46
+ import Stack.Types.PackageComponent (libraryPackage )
46
47
import Stack.Types.Package
47
48
import Stack.Types.SourceMap
48
49
import Stack.Types.Version
@@ -90,26 +91,29 @@ data AddDepRes
90
91
91
92
type ParentMap = MonoidMap PackageName (First Version , [(PackageIdentifier , VersionRange )])
92
93
93
- data W = W
94
- { wFinals :: ! (Map PackageName (Either ConstructPlanException Task ))
95
- , wInstall :: ! (Map Text InstallLocation )
94
+ data PlanDraft = PlanDraft
95
+ { pdFinals :: ! (Map PackageName (Either ConstructPlanException Task ))
96
+ , pdInstall :: ! (Map Text InstallLocation )
96
97
-- ^ executable to be installed, and location where the binary is placed
97
- , wDirty :: ! (Map PackageName Text )
98
+ , pdDirty :: ! (Map PackageName Text )
98
99
-- ^ why a local package is considered dirty
99
- , wWarnings :: ! ([Text ] -> [Text ])
100
+ , pdWarning :: ! ([Text ] -> [Text ])
100
101
-- ^ Warnings
101
- , wParents :: ! ParentMap
102
+ , pdParents :: ! ParentMap
102
103
-- ^ Which packages a given package depends on, along with the package's version
103
104
} deriving Generic
104
- instance Semigroup W where
105
+ instance Semigroup PlanDraft where
105
106
(<>) = mappenddefault
106
- instance Monoid W where
107
+ instance Monoid PlanDraft where
107
108
mempty = memptydefault
108
109
mappend = (<>)
109
110
111
+ -- | A monad transformer adding reading an environment of type 'Ctx',
112
+ -- collecting an output of type 'PlanDraft' and updating a state of type
113
+ -- '(Map PackageName (Either ConstructPlanException AddDepRes))' to an inner monad 'IO'.
110
114
type M = RWST -- TODO replace with more efficient WS stack on top of StackT
111
115
Ctx
112
- W
116
+ PlanDraft
113
117
(Map PackageName (Either ConstructPlanException AddDepRes ))
114
118
IO
115
119
@@ -188,7 +192,7 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap
188
192
let inner = mapM_ onTarget $ Map. keys (smtTargets $ smTargets sourceMap)
189
193
pathEnvVar' <- liftIO $ maybe mempty T. pack <$> lookupEnv " PATH"
190
194
let ctx = mkCtx econfig globalCabalVersion sources mcur pathEnvVar'
191
- (() , m, W efinals installExes dirtyReason warnings parents) <-
195
+ (() , m, PlanDraft efinals installExes dirtyReason warnings parents) <-
192
196
liftIO $ runRWST inner ctx M. empty
193
197
mapM_ (logWarn . RIO. display) (warnings [] )
194
198
let toEither (_, Left e) = Left e
@@ -200,7 +204,7 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap
200
204
then do
201
205
let toTask (_, ADRFound _ _) = Nothing
202
206
toTask (name, ADRToInstall task) = Just (name, task)
203
- tasks = M. fromList $ mapMaybe toTask adrs
207
+ tasks = first libraryPackage $ M. fromList $ mapMaybe toTask adrs
204
208
takeSubset =
205
209
case boptsCLIBuildSubset $ bcoBuildOptsCLI baseConfigOpts0 of
206
210
BSAll -> pure
@@ -412,7 +416,7 @@ addFinal lp package isAllInOne buildHaddocks = do
412
416
, taskAnyMissing = not $ Set. null missing
413
417
, taskBuildTypeConfig = packageBuildTypeConfig package
414
418
}
415
- tell mempty { wFinals = Map. singleton (packageName package) res }
419
+ tell mempty { pdFinals = Map. singleton (packageName package) res }
416
420
417
421
-- | Given a 'PackageName', adds all of the build tasks to build the
418
422
-- package, if needed.
@@ -513,7 +517,7 @@ tellExecutablesPackage loc p = do
513
517
| otherwise = Set. empty
514
518
goSource PSRemote {} = Set. empty
515
519
516
- tell mempty { wInstall = Map. fromList $ map (, loc) $ Set. toList $ filterComps myComps $ packageExes p }
520
+ tell mempty { pdInstall = Map. fromList $ map (, loc) $ Set. toList $ filterComps myComps $ packageExes p }
517
521
where
518
522
filterComps myComps x
519
523
| Set. null myComps = x
@@ -618,7 +622,7 @@ installPackageGivenDeps isAllInOne buildHaddocks ps package minstalled (missing,
618
622
return $ if shouldInstall then Nothing else Just installed
619
623
(Just _, False ) -> do
620
624
let t = T. intercalate " , " $ map (T. pack . packageNameString . pkgName) (Set. toList missing)
621
- tell mempty { wDirty = Map. singleton name $ " missing dependencies: " <> addEllipsis t }
625
+ tell mempty { pdDirty = Map. singleton name $ " missing dependencies: " <> addEllipsis t }
622
626
return Nothing
623
627
(Nothing , _) -> return Nothing
624
628
let loc = psLocation ps
@@ -716,7 +720,7 @@ addPackageDeps package = do
716
720
then return True
717
721
else do
718
722
let warn_ reason =
719
- tell mempty { wWarnings = (msg: ) }
723
+ tell mempty { pdWarning = (msg: ) }
720
724
where
721
725
msg = T. concat
722
726
[ " WARNING: Ignoring "
@@ -771,7 +775,7 @@ addPackageDeps package = do
771
775
adrVersion (ADRFound _ installed) = installedVersion installed
772
776
-- Update the parents map, for later use in plan construction errors
773
777
-- - see 'getShortestDepsPath'.
774
- addParent depname range mversion = tell mempty { wParents = MonoidMap $ M. singleton depname val }
778
+ addParent depname range mversion = tell mempty { pdParents = MonoidMap $ M. singleton depname val }
775
779
where
776
780
val = (First mversion, [(packageIdentifier package, range)])
777
781
@@ -837,7 +841,7 @@ checkDirtiness ps installed package present buildHaddocks = do
837
841
case mreason of
838
842
Nothing -> return False
839
843
Just reason -> do
840
- tell mempty { wDirty = Map. singleton (packageName package) reason }
844
+ tell mempty { pdDirty = Map. singleton (packageName package) reason }
841
845
return True
842
846
843
847
describeConfigDiff :: Config -> ConfigCache -> ConfigCache -> Maybe Text
@@ -935,7 +939,7 @@ packageDepsWithTools p = do
935
939
case mfound of
936
940
Left _ -> return $ Just $ ToolWarning name (packageName p)
937
941
Right _ -> return Nothing
938
- tell mempty { wWarnings = (map toolWarningText warnings ++ ) }
942
+ tell mempty { pdWarning = (map toolWarningText warnings ++ ) }
939
943
return $ packageDeps p
940
944
941
945
-- | Warn about tools in the snapshot definition. States the tool name
0 commit comments