getInstalledPackage :: PackageName -> FilePath -> IO (Maybe InstalledPackageInfo)
getInstalledPackage pkgname pkgdir = do
  let pkgconfFile = pkgdir </> "package.conf"
  pkgconfExists <- doesFileExist pkgconfFile

  let pathsModule = pkgdir </> ("Paths_" ++ display pkgname)  <.> "hs"
  pathsModuleExists <- doesFileExist pathsModule

  case () of
    _ | pkgconfExists     -> getFullInstalledPackageInfo pkgname pkgconfFile
      | pathsModuleExists -> getPhonyInstalledPackageInfo pkgname pathsModule
      | otherwise         -> return Nothing
getInstalledPackage :: PackageName -> FilePath -> IO (Maybe InstalledPackageInfo)
getInstalledPackage pkgname pkgdir = do
  let pkgconfFile = pkgdir </> "package.conf"
  pkgconfExists <- doesFileExist pkgconfFile

  let pathsModule = pkgdir </> ("Paths_" ++ display pkgname)  <.> "hs"
  pathsModuleExists <- doesFileExist pathsModule

  case () of
    _ | pkgconfExists     -> getFullInstalledPackageInfo pkgname pkgconfFile
      | pathsModuleExists -> getPhonyInstalledPackageInfo pkgname pathsModule
      | otherwise         -> return Nothing
getInstalledPackage pkgname pkgdir = do
  let pkgconfFile = pkgdir </> "package.conf"
  pkgconfExists <- doesFileExist pkgconfFile

  let pathsModule = pkgdir </> ("Paths_" ++ display pkgname)  <.> "hs"
  pathsModuleExists <- doesFileExist pathsModule

  case () of
    _ | pkgconfExists     -> getFullInstalledPackageInfo pkgname pkgconfFile
      | pathsModuleExists -> getPhonyInstalledPackageInfo pkgname pathsModule
      | otherwise         -> return Nothing