-- | Get all the packages from the index.
--
-- They are grouped by source package id (package name and version).
--
allPackagesBySourcePackageId :: HasUnitId a => PackageIndex a
                             -> [(PackageId, [a])]
allPackagesBySourcePackageId index =
  [ (packageId ipkg, ipkgs)
  | pvers <- Map.elems (packageIdIndex index)
  , ipkgs@(ipkg:_) <- Map.elems pvers ]
allPackagesBySourcePackageId :: HasUnitId a => PackageIndex a
                             -> [(PackageId, [a])]
allPackagesBySourcePackageId index =
  [ (packageId ipkg, ipkgs)
  | pvers <- Map.elems (packageIdIndex index)
  , ipkgs@(ipkg:_) <- Map.elems pvers ]
allPackagesBySourcePackageId index =
  [ (packageId ipkg, ipkgs)
  | pvers <- Map.elems (packageIdIndex index)
  , ipkgs@(ipkg:_) <- Map.elems pvers ]