mkQualModule :: DynFlags -> QueryQualifyModule
mkQualModule dflags mod
     | modulePackageKey mod == thisPackage dflags = False

     | [(_, pkgconfig)] <- lookup,
       packageConfigId pkgconfig == modulePackageKey mod
        -- this says: we are given a module P:M, is there just one exposed package
        -- that exposes a module M, and is it package P?
     = False

     | otherwise = True
     where lookup = lookupModuleInAllPackages dflags (moduleName mod)

-- | Creates a function for formatting packages based on two heuristics:
-- (1) don't qualify if the package in question is "main", and (2) only qualify
-- with a package key if the package ID would be ambiguous.
mkQualModule :: DynFlags -> QueryQualifyModule
mkQualModule dflags mod
     | modulePackageKey mod == thisPackage dflags = False

     | [(_, pkgconfig)] <- lookup,
       packageConfigId pkgconfig == modulePackageKey mod
        -- this says: we are given a module P:M, is there just one exposed package
        -- that exposes a module M, and is it package P?
     = False

     | otherwise = True
     where lookup = lookupModuleInAllPackages dflags (moduleName mod)

-- | Creates a function for formatting packages based on two heuristics:
-- (1) don't qualify if the package in question is "main", and (2) only qualify
-- with a package key if the package ID would be ambiguous.
mkQualModule dflags mod
     | modulePackageKey mod == thisPackage dflags = False

     | [(_, pkgconfig)] <- lookup,
       packageConfigId pkgconfig == modulePackageKey mod
        -- this says: we are given a module P:M, is there just one exposed package
        -- that exposes a module M, and is it package P?
     = False

     | otherwise = True
     where lookup = lookupModuleInAllPackages dflags (moduleName mod)

-- | Creates a function for formatting packages based on two heuristics:
-- (1) don't qualify if the package in question is "main", and (2) only qualify
-- with a package key if the package ID would be ambiguous.