-- | Sometimes we need to convert a 'ReadyPackage' back to a
-- 'ConfiguredPackage'. For example, a failed 'PlanPackage' can be *either*
-- Ready or Configured.
readyPackageToConfiguredPackage :: ReadyPackage -> ConfiguredPackage
readyPackageToConfiguredPackage (ReadyPackage srcpkg flags stanzas deps) =
    ConfiguredPackage srcpkg flags stanzas (fmap (map aux) deps)
  where
    aux :: InstalledPackageInfo -> ConfiguredId
    aux info = ConfiguredId {
        confSrcId  = Info.sourcePackageId info
      , confInstId = installedPackageId info
      }


-- | A package description along with the location of the package sources.
--
readyPackageToConfiguredPackage :: ReadyPackage -> ConfiguredPackage
readyPackageToConfiguredPackage (ReadyPackage srcpkg flags stanzas deps) =
    ConfiguredPackage srcpkg flags stanzas (fmap (map aux) deps)
  where
    aux :: InstalledPackageInfo -> ConfiguredId
    aux info = ConfiguredId {
        confSrcId  = Info.sourcePackageId info
      , confInstId = installedPackageId info
      }


-- | A package description along with the location of the package sources.
--
readyPackageToConfiguredPackage (ReadyPackage srcpkg flags stanzas deps) =
    ConfiguredPackage srcpkg flags stanzas (fmap (map aux) deps)
  where
    aux :: InstalledPackageInfo -> ConfiguredId
    aux info = ConfiguredId {
        confSrcId  = Info.sourcePackageId info
      , confInstId = installedPackageId info
      }


-- | A package description along with the location of the package sources.
--