Skip to content

Commit

Permalink
Remove same-package import lists, fixes haskell#2835.
Browse files Browse the repository at this point in the history
Instead of qualifying, in some cases I just added an extra
'hiding' pragma to squelch errors.

Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Jan 3, 2016
1 parent f09d65f commit 4993907
Show file tree
Hide file tree
Showing 64 changed files with 400 additions and 898 deletions.
1 change: 1 addition & 0 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ library
Distribution.Simple.GHC.Internal
Distribution.Simple.GHC.IPI641
Distribution.Simple.GHC.IPI642
Distribution.Simple.GHC.IPIConvert
Distribution.Simple.GHC.ImplInfo
Paths_Cabal

Expand Down
6 changes: 2 additions & 4 deletions Cabal/Distribution/Compat/CopyFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ module Distribution.Compat.CopyFile (
setDirOrdinary,
) where

import Distribution.Compat.Exception
import Distribution.Compat.Internal.TempFile

import Control.Monad
( when, unless )
import Control.Exception
( bracketOnError, throwIO )
import qualified Data.ByteString.Lazy as BSL
import Distribution.Compat.Exception
( catchIO )
import System.IO.Error
( ioeSetLocation )
import System.Directory
( doesFileExist, renameFile, removeFile )
import Distribution.Compat.Internal.TempFile
( openBinaryTempFile )
import System.FilePath
( takeDirectory )
import System.IO
Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/Compat/Internal/TempFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Distribution.Compat.Internal.TempFile (
createTempDirectory,
) where

import Distribution.Compat.Exception

import System.FilePath ((</>))
import Foreign.C (CInt, eEXIST, getErrno, errnoToIOError)
Expand All @@ -18,7 +19,6 @@ import System.Posix.Internals (c_open, c_close, o_CREAT, o_EXCL, o_RDWR,
withFilePath, c_getpid)
import System.IO.Error (isAlreadyExistsError)
import GHC.IO.Handle.FD (fdToHandle)
import Distribution.Compat.Exception (tryIO)
import Control.Exception (onException)

#if defined(mingw32_HOST_OS) || defined(ghcjs_HOST_OS)
Expand Down
6 changes: 3 additions & 3 deletions Cabal/Distribution/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ module Distribution.Compiler (
AbiTag(..), abiTagString
) where

import Distribution.Compat.Binary (Binary)
import Distribution.Compat.Binary
import Language.Haskell.Extension

import Data.Data (Data)
import Data.Typeable (Typeable)
import Data.Maybe (fromMaybe)
import Distribution.Version (Version(..))
import GHC.Generics (Generic)

import Language.Haskell.Extension (Language, Extension)

import qualified System.Info (compilerName, compilerVersion)
import Distribution.Text (Text(..), display)
import qualified Distribution.Compat.ReadP as Parse
Expand Down
45 changes: 8 additions & 37 deletions Cabal/Distribution/InstalledPackageInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
-- This module is meant to be local-only to Distribution...

module Distribution.InstalledPackageInfo (
AbiHash(..),
InstalledPackageInfo(..),
OriginalModule(..), ExposedModule(..),
ParseResult(..), PError(..), PWarning,
Expand All @@ -40,32 +39,18 @@ module Distribution.InstalledPackageInfo (
) where

import Distribution.ParseUtils
( FieldDescr(..), ParseResult(..), PError(..), PWarning
, simpleField, listField, parseLicenseQ
, showFields, showSingleNamedField, showSimpleSingleNamedField
, parseFieldsFlat
, parseFilePathQ, parseTokenQ, parseModuleNameQ, parsePackageNameQ
, showFilePath, showToken, boolField, parseOptVersion
, parseFreeText, showFreeText, parseOptCommaList )
import Distribution.License ( License(..) )
import Distribution.Package
( PackageName(..), PackageIdentifier(..)
, PackageId, ComponentId(..)
, packageName, packageVersion, ComponentId(..) )
import Distribution.License
import Distribution.Package hiding (installedComponentId)
import qualified Distribution.Package as Package
import Distribution.ModuleName
( ModuleName )
import Distribution.Version
( Version(..) )
import Distribution.Text
( Text(disp, parse) )
import Text.PrettyPrint as Disp
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.Binary

import Distribution.Compat.Binary (Binary)
import Text.PrettyPrint as Disp
import Data.Maybe (fromMaybe)
import GHC.Generics (Generic)
import qualified Data.Char as Char

-- -----------------------------------------------------------------------------
-- The InstalledPackageInfo type
Expand All @@ -92,7 +77,7 @@ data InstalledPackageInfo
abiHash :: AbiHash,
exposed :: Bool,
exposedModules :: [ExposedModule],
instantiatedWith :: [(ModuleName, OriginalModule)],
installedInstantiatedWith :: [(ModuleName, OriginalModule)],
hiddenModules :: [ModuleName],
trusted :: Bool,
importDirs :: [FilePath],
Expand Down Expand Up @@ -128,7 +113,7 @@ instance Package.PackageInstalled InstalledPackageInfo where
emptyInstalledPackageInfo :: InstalledPackageInfo
emptyInstalledPackageInfo
= InstalledPackageInfo {
sourcePackageId = PackageIdentifier (PackageName "") noVersion,
sourcePackageId = PackageIdentifier (PackageName "") (Version [] []),
installedComponentId = ComponentId "",
compatPackageKey = ComponentId "",
license = UnspecifiedLicense,
Expand All @@ -145,7 +130,7 @@ emptyInstalledPackageInfo
exposed = False,
exposedModules = [],
hiddenModules = [],
instantiatedWith = [],
installedInstantiatedWith = [],
trusted = False,
importDirs = [],
libraryDirs = [],
Expand All @@ -165,20 +150,6 @@ emptyInstalledPackageInfo
pkgRoot = Nothing
}

noVersion :: Version
noVersion = Version [] []

-- -----------------------------------------------------------------------------
-- Exposed modules

newtype AbiHash = AbiHash String
deriving (Eq, Show, Read, Generic)
instance Binary AbiHash

instance Text AbiHash where
disp (AbiHash abi) = Disp.text abi
parse = fmap AbiHash (Parse.munch Char.isAlphaNum)

-- -----------------------------------------------------------------------------
-- Exposed modules

Expand Down Expand Up @@ -348,7 +319,7 @@ installedFieldDescrs = [
abiHash (\abi pkg -> pkg{abiHash=abi})
, listField "instantiated-with"
showInstantiatedWith parseInstantiatedWith
instantiatedWith (\xs pkg -> pkg{instantiatedWith=xs})
installedInstantiatedWith (\xs pkg -> pkg{installedInstantiatedWith=xs})
, boolField "trusted"
trusted (\val pkg -> pkg{trusted=val})
, listField "import-dirs"
Expand Down
8 changes: 4 additions & 4 deletions Cabal/Distribution/License.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ module Distribution.License (
knownLicenses,
) where

import Distribution.Version (Version(Version))

import Distribution.Text (Text(..), display)
import Distribution.Version
import Distribution.Text
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.Binary

import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import Distribution.Compat.Binary (Binary)
import qualified Data.Char as Char (isAlphaNum)
import Data.Data (Data)
import Data.Typeable (Typeable)
Expand Down
11 changes: 4 additions & 7 deletions Cabal/Distribution/Make.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,19 @@ module Distribution.Make (

-- local
import Distribution.Compat.Exception
import Distribution.Package --must not specify imports, since we're exporting moule.
import Distribution.Simple.Program(defaultProgramConfiguration)
import Distribution.Package
import Distribution.Simple.Program
import Distribution.PackageDescription
import Distribution.Simple.Setup
import Distribution.Simple.Command

import Distribution.Simple.Utils (rawSystemExit, cabalVersion)
import Distribution.Simple.Utils

import Distribution.License (License(..))
import Distribution.License
import Distribution.Version
( Version(..) )
import Distribution.Text
( display )

import System.Environment (getArgs, getProgName)
import Data.List (intercalate)
import System.Exit

defaultMain :: IO ()
Expand Down
5 changes: 2 additions & 3 deletions Cabal/Distribution/ModuleName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ module Distribution.ModuleName (
) where

import Distribution.Text
( Text(..) )
import Distribution.Compat.Binary
import qualified Distribution.Compat.ReadP as Parse

import Distribution.Compat.Binary (Binary)
import qualified Data.Char as Char
( isAlphaNum, isUpper )
import Data.Data (Data)
import Data.Typeable (Typeable)
import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
import Data.List
( intercalate, intersperse )
Expand Down
20 changes: 17 additions & 3 deletions Cabal/Distribution/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module Distribution.Package (
getHSLibraryName,
InstalledPackageId, -- backwards compat

-- * ABI hash
AbiHash(..),

-- * Package source dependencies
Dependency(..),
thisPackageVersion,
Expand All @@ -42,13 +45,13 @@ import Distribution.Version
( Version(..), VersionRange, anyVersion, thisVersion
, notThisVersion, simplifyVersionRange )

import Distribution.Text (Text(..))
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((<++))
import qualified Text.PrettyPrint as Disp
import Distribution.Compat.ReadP
import Distribution.Compat.Binary
import Distribution.Text

import Control.DeepSeq (NFData(..))
import Distribution.Compat.Binary (Binary)
import qualified Data.Char as Char
( isDigit, isAlphaNum, )
import Data.Data ( Data )
Expand Down Expand Up @@ -202,3 +205,14 @@ class Package pkg => HasComponentId pkg where
-- Installed packages have exact dependencies 'installedDepends'.
class (HasComponentId pkg) => PackageInstalled pkg where
installedDepends :: pkg -> [ComponentId]

-- -----------------------------------------------------------------------------
-- ABI hash

newtype AbiHash = AbiHash String
deriving (Eq, Show, Read, Generic)
instance Binary AbiHash

instance Text AbiHash where
disp (AbiHash abi) = Disp.text abi
parse = fmap AbiHash (Parse.munch Char.isAlphaNum)
30 changes: 12 additions & 18 deletions Cabal/Distribution/PackageDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,20 @@ module Distribution.PackageDescription (
SetupBuildInfo(..),
) where

import Distribution.Compat.Binary (Binary)
import Distribution.Compat.Binary
import qualified Distribution.Compat.Semigroup as Semi ((<>))
import Distribution.Compat.Semigroup as Semi (Monoid(..), Semigroup)
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((<++))
import Distribution.Package
import Distribution.ModuleName
import Distribution.Version
import Distribution.License
import Distribution.Compiler
import Distribution.System
import Distribution.Text
import Language.Haskell.Extension

import Data.Data (Data)
import Data.Foldable (traverse_)
import Data.List (nub, intercalate)
Expand All @@ -123,27 +134,10 @@ import Control.Applicative as AP (Alternative(..), Applicative(..))
import Control.Monad (MonadPlus(mplus,mzero), ap)
import GHC.Generics (Generic)
import Text.PrettyPrint as Disp
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((<++))
import qualified Data.Char as Char (isAlphaNum, isDigit, toLower)
import qualified Data.Map as Map
import Data.Map (Map)

import Distribution.Package
( PackageName(PackageName), PackageIdentifier(PackageIdentifier)
, Dependency, Package(..), PackageName, packageName )
import Distribution.ModuleName ( ModuleName )
import Distribution.Version
( Version(Version), VersionRange, anyVersion, orLaterVersion
, asVersionIntervals, LowerBound(..) )
import Distribution.License (License(UnspecifiedLicense))
import Distribution.Compiler (CompilerFlavor)
import Distribution.System (OS, Arch)
import Distribution.Text
( Text(..), display )
import Language.Haskell.Extension
( Language, Extension )

-- -----------------------------------------------------------------------------
-- The PackageDescription type

Expand Down
Loading

0 comments on commit 4993907

Please sign in to comment.