Skip to content

Commit

Permalink
Rationalise ParentMap type synonym, given its actual use
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Oct 23, 2023
1 parent d5ed464 commit 56f9b35
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ addPackageDeps package = do
Just (lappVer, cabalHash)
case eres of
Left e -> do
addParent depname range Nothing
addParent depname range
let bd = case e of
UnknownPackage name -> assert (name == depname) NotInBuildPlan
DependencyCycleDetected names -> BDDependencyCycleDetected names
Expand All @@ -921,7 +921,7 @@ addPackageDeps package = do
Right adr | depType == AsLibrary && not (adrHasLibrary adr) ->
pure $ Left (depname, (range, Nothing, HasNoLibrary))
Right adr -> do
addParent depname range Nothing
addParent depname range
inRange <- if adrVersion adr `withinRange` range
then pure True
else do
Expand Down Expand Up @@ -1038,10 +1038,9 @@ addPackageDeps package = do
adrVersion (ADRFound _ installed) = installedVersion installed
-- Update the parents map, for later use in plan construction errors
-- - see 'getShortestDepsPath'.
addParent depname range mversion =
tell mempty { wParents = MonoidMap $ Map.singleton depname val }
addParent depname range = tell mempty { wParents = MonoidMap parentMap }
where
val = (First mversion, [(packageIdentifier package, range)])
parentMap = Map.singleton depname [(packageIdentifier package, range)]

adrHasLibrary :: AddDepRes -> Bool
adrHasLibrary (ADRToInstall task) = taskHasLibrary task
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Types/Build/Exception.hs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ getShortestDepsPath (MonoidMap parentsMap) wanted' name =
then Just []
else case M.lookup name parentsMap of
Nothing -> Nothing
Just (_, parents) -> Just $ findShortest 256 paths0
Just parents -> Just $ findShortest 256 paths0
where
paths0 = M.fromList $
map (\(ident, _) -> (pkgName ident, startDepsPath ident)) parents
Expand Down Expand Up @@ -869,7 +869,7 @@ getShortestDepsPath (MonoidMap parentsMap) wanted' name =
extendPath (n, dp) =
case M.lookup n parentsMap of
Nothing -> []
Just (_, parents) ->
Just parents ->
map (\(pkgId, _) -> (pkgName pkgId, extendDepsPath pkgId dp)) parents

startDepsPath :: PackageIdentifier -> DepsPath
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Types/ParentMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import Stack.Prelude
import Stack.Types.Version ( VersionRange )

type ParentMap =
MonoidMap PackageName (First Version, [(PackageIdentifier, VersionRange)])
MonoidMap PackageName [(PackageIdentifier, VersionRange)]

0 comments on commit 56f9b35

Please sign in to comment.