mkQualPackage :: DynFlags -> QueryQualifyPackage
mkQualPackage dflags pkg_key
     | pkg_key == mainPackageKey || pkg_key == interactivePackageKey
        -- Skip the lookup if it's main, since it won't be in the package
        -- database!
     = False
     | searchPackageId dflags pkgid `lengthIs` 1
        -- this says: we are given a package pkg-0.1@MMM, are there only one
        -- exposed packages whose package ID is pkg-0.1?
     = False
     | otherwise
     = True
     where pkg = fromMaybe (pprPanic "qual_pkg" (ftext (packageKeyFS pkg_key)))
                    (lookupPackage dflags pkg_key)
           pkgid = sourcePackageId pkg

-- | A function which only qualifies package names if necessary; but
-- qualifies all other identifiers.
mkQualPackage :: DynFlags -> QueryQualifyPackage
mkQualPackage dflags pkg_key
     | pkg_key == mainPackageKey || pkg_key == interactivePackageKey
        -- Skip the lookup if it's main, since it won't be in the package
        -- database!
     = False
     | searchPackageId dflags pkgid `lengthIs` 1
        -- this says: we are given a package pkg-0.1@MMM, are there only one
        -- exposed packages whose package ID is pkg-0.1?
     = False
     | otherwise
     = True
     where pkg = fromMaybe (pprPanic "qual_pkg" (ftext (packageKeyFS pkg_key)))
                    (lookupPackage dflags pkg_key)
           pkgid = sourcePackageId pkg

-- | A function which only qualifies package names if necessary; but
-- qualifies all other identifiers.
mkQualPackage dflags pkg_key
     | pkg_key == mainPackageKey || pkg_key == interactivePackageKey
        -- Skip the lookup if it's main, since it won't be in the package
        -- database!
     = False
     | searchPackageId dflags pkgid `lengthIs` 1
        -- this says: we are given a package pkg-0.1@MMM, are there only one
        -- exposed packages whose package ID is pkg-0.1?
     = False
     | otherwise
     = True
     where pkg = fromMaybe (pprPanic "qual_pkg" (ftext (packageKeyFS pkg_key)))
                    (lookupPackage dflags pkg_key)
           pkgid = sourcePackageId pkg

-- | A function which only qualifies package names if necessary; but
-- qualifies all other identifiers.