...
 
Commits (29)
......@@ -2,6 +2,7 @@
# The following enables several GHC versions to be tested; often it's enough to test only against the last release in a major GHC version. Feel free to omit lines listings versions you don't need/want testing for.
env:
- GHCVER=7.2.2
- GHCVER=7.4.2
- GHCVER=7.6.3
- GHCVER=7.8.3
......@@ -45,9 +46,10 @@ script:
- cd ../cabal-install
- cabal sandbox init
- cabal sandbox add-source ../Cabal
- cabal install --dependencies-only
- cabal configure
- cabal install --dependencies-only --enable-tests
- cabal configure --enable-tests
- cabal build
- cabal test
- cabal check
- cabal sdist
- install_from_tarball
......
......@@ -128,16 +128,21 @@ source-repository head
library
build-depends:
base >= 4.2 && < 5,
binary >= 0.7 && < 0.8,
deepseq >= 1.3 && < 1.4,
filepath >= 1 && < 1.4,
directory >= 1 && < 1.3,
process >= 1.1.0.1 && < 1.3,
time >= 1.1 && < 1.5,
time >= 1.1 && < 1.6,
containers >= 0.1 && < 0.6,
array >= 0.1 && < 0.6,
pretty >= 1 && < 1.2,
bytestring >= 0.9
-- Needed for GHC.Generics before GHC 7.6
if impl(ghc < 7.6)
build-depends: ghc-prim >= 0.2 && < 0.3
if !os(windows)
build-depends:
unix >= 2.0 && < 2.8
......@@ -154,7 +159,6 @@ library
Distribution.License
Distribution.Make
Distribution.ModuleName
Distribution.ModuleExport
Distribution.Package
Distribution.PackageDescription
Distribution.PackageDescription.Check
......@@ -285,6 +289,7 @@ test-suite package-tests
hs-source-dirs: tests
build-depends:
base,
binary >= 0.7 && < 0.8,
test-framework,
test-framework-quickcheck2 >= 0.2.12,
test-framework-hunit,
......
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Compiler
......@@ -35,10 +37,12 @@ module Distribution.Compiler (
CompilerId(..),
) where
import Data.Binary (Binary)
import Data.Data (Data)
import Data.Typeable (Typeable)
import Data.Maybe (fromMaybe)
import Distribution.Version (Version(..))
import GHC.Generics (Generic)
import qualified System.Info (compilerName, compilerVersion)
import Distribution.Text (Text(..), display)
......@@ -52,7 +56,9 @@ import Control.Monad (when)
data CompilerFlavor = GHC | NHC | YHC | Hugs | HBC | Helium | JHC | LHC | UHC
| HaskellSuite String -- string is the id of the actual compiler
| OtherCompiler String
deriving (Show, Read, Eq, Ord, Typeable, Data)
deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)
instance Binary CompilerFlavor
knownCompilerFlavors :: [CompilerFlavor]
knownCompilerFlavors = [GHC, NHC, YHC, Hugs, HBC, Helium, JHC, LHC, UHC]
......@@ -125,7 +131,9 @@ defaultCompilerFlavor = case buildCompilerFlavor of
-- ------------------------------------------------------------
data CompilerId = CompilerId CompilerFlavor Version
deriving (Eq, Ord, Read, Show)
deriving (Eq, Generic, Ord, Read, Show)
instance Binary CompilerId
instance Text CompilerId where
disp (CompilerId f (Version [] _)) = disp f
......
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.InstalledPackageInfo
......@@ -56,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.InstalledPackageInfo (
InstalledPackageInfo_(..), InstalledPackageInfo,
ModuleReexport(..),
ParseResult(..), PError(..), PWarning,
emptyInstalledPackageInfo,
parseInstalledPackageInfo,
......@@ -79,15 +82,17 @@ import Distribution.Package
, PackageId, InstalledPackageId(..)
, packageName, packageVersion, PackageKey(..) )
import qualified Distribution.Package as Package
( Package(..) )
import Distribution.ModuleName
( ModuleName )
import Distribution.ModuleExport
( ModuleExport(..) )
import Distribution.Version
( Version(..) )
import Distribution.Text
( Text(disp, parse) )
import Text.PrettyPrint as Disp
import qualified Distribution.Compat.ReadP as Parse
import Data.Binary (Binary)
import GHC.Generics (Generic)
-- -----------------------------------------------------------------------------
-- The InstalledPackageInfo type
......@@ -112,7 +117,7 @@ data InstalledPackageInfo_ m
-- these parts are required by an installed package only:
exposed :: Bool,
exposedModules :: [m],
reexportedModules :: [ModuleExport m],
reexportedModules :: [ModuleReexport],
hiddenModules :: [m],
trusted :: Bool,
importDirs :: [FilePath], -- contain sources in case of Hugs
......@@ -131,11 +136,17 @@ data InstalledPackageInfo_ m
haddockInterfaces :: [FilePath],
haddockHTMLs :: [FilePath]
}
deriving (Read, Show)
deriving (Generic, Read, Show)
instance Binary m => Binary (InstalledPackageInfo_ m)
instance Package.Package (InstalledPackageInfo_ str) where
packageId = sourcePackageId
instance Package.PackageInstalled (InstalledPackageInfo_ str) where
installedPackageId = installedPackageId
installedDepends = depends
type InstalledPackageInfo = InstalledPackageInfo_ ModuleName
emptyInstalledPackageInfo :: InstalledPackageInfo_ m
......@@ -180,6 +191,33 @@ emptyInstalledPackageInfo
noVersion :: Version
noVersion = Version{ versionBranch=[], versionTags=[] }
-- -----------------------------------------------------------------------------
-- Module re-exports
data ModuleReexport = ModuleReexport {
moduleReexportDefiningPackage :: InstalledPackageId,
moduleReexportDefiningName :: ModuleName,
moduleReexportName :: ModuleName
}
deriving (Generic, Read, Show)
instance Binary ModuleReexport
instance Text ModuleReexport where
disp (ModuleReexport pkgid origname newname) =
disp pkgid <> Disp.char ':' <> disp origname
<+> Disp.text "as" <+> disp newname
parse = do
pkgid <- parse
_ <- Parse.char ':'
origname <- parse
Parse.skipSpaces
_ <- Parse.string "as"
Parse.skipSpaces
newname <- parse
return (ModuleReexport pkgid origname newname)
-- -----------------------------------------------------------------------------
-- Parsing
......
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.License
......@@ -51,9 +53,11 @@ import Distribution.Text (Text(..), display)
import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import Data.Binary (Binary)
import qualified Data.Char as Char (isAlphaNum)
import Data.Data (Data)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
-- | Indicates the license under which a package's source code is released.
-- Versions of the licenses not listed here will be rejected by Hackage and
......@@ -110,7 +114,9 @@ data License =
-- | Indicates an erroneous license name.
| UnknownLicense String
deriving (Read, Show, Eq, Typeable, Data)
deriving (Generic, Read, Show, Eq, Typeable, Data)
instance Binary License
-- | The list of all currently recognised licenses.
knownLicenses :: [License]
......
{-# LANGUAGE DeriveDataTypeable #-}
module Distribution.ModuleExport(ModuleExport(..)) where
import Distribution.Text
( Text(disp, parse) )
import Distribution.Compat.ReadP
( (+++) )
import Distribution.Package
( PackageName, InstalledPackageId )
import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<+>),(<>))
import Data.Data
-- | Defines a reexport of module 'exportOrigName' from package
-- 'exportOrigPackageId' as new module name 'exportName'. This data type has an
-- interesting invariant: in the installed package database, a ModuleExport is
-- guaranteed to point to the original module which defined the module. Of
-- course, when a user writes a ModuleExport, it may not have this property.
-- ghc-pkg is responsible for enforcing this invariant.
data ModuleExport m = ModuleExport {
-- | Original package name of the reexported module, or Nothing if
-- the user wants us to figure it out automatically. (Note: this package
-- could have reexported the module itself.)
exportOrigPackageName :: Maybe PackageName,
-- | Original module name of reexported module.
exportOrigName :: m,
-- | New module name of reexported module, available to clients
-- of this package.
exportName :: m,
-- | A hack! When ghc-pkg processes 'ModuleExport', it is able to resolve
-- the true, original location an identifier lived in (this cannot be done
-- without consulting the package database), it fills it in here so that
-- GHC can use it. When we get GHC to stop using 'InstalledPackageInfo',
-- this hack can go away.
exportCachedTrueOrig :: Maybe (InstalledPackageId, m)
} deriving (Read, Show, Eq, Data, Typeable)
-- Handy when we need to convert from one ModuleName representation to
-- another (it's used in GHC.)
instance Functor ModuleExport where
fmap f (ModuleExport pnm m m' c) = ModuleExport pnm (f m) (f m')
(fmap (\(x,y)->(x,f y)) c)
instance (Eq m, Text m) => Text (ModuleExport m) where
disp ModuleExport{ exportOrigPackageName = mpnm
, exportOrigName = m
, exportName = m'
, exportCachedTrueOrig = c }
= (maybe Disp.empty (\pnm -> disp pnm <> Disp.char ':') mpnm)
<> disp m
<+> (if m == m'
then Disp.empty
else Disp.text "as" <+> disp m')
<+> (maybe Disp.empty (\(c_ipid, c_m) ->
Disp.parens (disp c_m <> Disp.char '@' <> disp c_ipid)) c)
parse = do Parse.skipSpaces
mpnm <- (do pnm <- parse
_ <- Parse.char ':'
return (Just pnm)
+++ return Nothing)
m <- parse
m' <- (do Parse.skipSpaces
_ <- Parse.string "as"
Parse.skipSpaces
parse)
+++ return m
c <- (do Parse.skipSpaces
_ <- Parse.char '('
c_m <- parse
_ <- Parse.char '@'
c_ipid <- parse
_ <- Parse.char ')'
return (Just (c_ipid, c_m))
+++ return Nothing)
return ModuleExport{ exportOrigPackageName = mpnm
, exportOrigName = m
, exportName = m'
, exportCachedTrueOrig = c }
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.ModuleName
......@@ -22,21 +24,25 @@ module Distribution.ModuleName (
import Distribution.Text
( Text(..) )
import Data.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 qualified Data.Char as Char
( isAlphaNum, isUpper )
import System.FilePath
( pathSeparator )
import Data.List
( intercalate, intersperse )
import GHC.Generics (Generic)
import System.FilePath
( pathSeparator )
-- | A valid Haskell module name.
--
newtype ModuleName = ModuleName [String]
deriving (Eq, Ord, Read, Show, Typeable, Data)
deriving (Eq, Generic, Ord, Read, Show, Typeable, Data)
instance Binary ModuleName
instance Text ModuleName where
disp (ModuleName ms) =
......
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Package
......@@ -35,6 +37,7 @@ module Distribution.Package (
-- * Package classes
Package(..), packageName, packageVersion,
PackageFixedDeps(..),
PackageInstalled(..),
) where
import Distribution.Version
......@@ -45,19 +48,24 @@ import Distribution.Text (Text(..))
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((<++))
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>), (<+>), text)
import Control.DeepSeq (NFData(..))
import Data.Binary (Binary)
import qualified Data.Char as Char
( isDigit, isAlphaNum, isUpper, isLower, ord, chr )
import Data.List ( intercalate, sort, foldl' )
import Data.Data ( Data )
import Data.List ( intercalate, sort, foldl' )
import Data.Typeable ( Typeable )
import GHC.Fingerprint ( Fingerprint(..), fingerprintString )
import Data.Word ( Word64 )
import GHC.Fingerprint ( Fingerprint(..), fingerprintString )
import GHC.Generics (Generic)
import Numeric ( showIntAtBase )
import Text.PrettyPrint ((<>), (<+>), text)
newtype PackageName = PackageName { unPackageName :: String }
deriving (Read, Show, Eq, Ord, Typeable, Data)
deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
instance Binary PackageName
instance Text PackageName where
disp (PackageName n) = Disp.text n
......@@ -83,7 +91,9 @@ data PackageIdentifier
pkgName :: PackageName, -- ^The name of this package, eg. foo
pkgVersion :: Version -- ^the version of this package, eg 1.2
}
deriving (Read, Show, Eq, Ord, Typeable, Data)
deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
instance Binary PackageIdentifier
instance Text PackageIdentifier where
disp (PackageIdentifier n v) = case v of
......@@ -107,13 +117,15 @@ instance NFData PackageIdentifier where
-- in a package database, or overlay of databases.
--
newtype InstalledPackageId = InstalledPackageId String
deriving (Read,Show,Eq,Ord,Typeable,Data)
deriving (Generic, Read,Show,Eq,Ord,Typeable,Data)
instance Binary InstalledPackageId
instance Text InstalledPackageId where
disp (InstalledPackageId str) = text str
parse = InstalledPackageId `fmap` Parse.munch1 abi_char
where abi_char c = Char.isAlphaNum c || c `elem` ":-_."
where abi_char c = Char.isAlphaNum c || c `elem` "-_."
-- ------------------------------------------------------------
-- * Package Keys
......@@ -136,7 +148,9 @@ data PackageKey
-- old versions of GHC assume that the 'sourcePackageId' recorded for an
-- installed package coincides with the package key it was compiled with.
| OldPackageKey !PackageId
deriving (Read, Show, Eq, Ord, Typeable, Data)
deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
instance Binary PackageKey
-- | Convenience function which converts a fingerprint into a new-style package
-- key.
......@@ -230,7 +244,9 @@ instance NFData PackageKey where
-- | Describes a dependency on a source package (API)
--
data Dependency = Dependency PackageName VersionRange
deriving (Read, Show, Eq, Typeable, Data)
deriving (Generic, Read, Show, Eq, Typeable, Data)
instance Binary Dependency
instance Text Dependency where
disp (Dependency name ver) =
......@@ -288,3 +304,13 @@ instance Package PackageIdentifier where
--
class Package pkg => PackageFixedDeps pkg where
depends :: pkg -> [PackageIdentifier]
-- | Class of installed packages.
--
-- The primary data type which is an instance of this package is
-- 'InstalledPackageInfo', but when we are doing install plans in Cabal install
-- we may have other, installed package-like things which contain more metadata.
-- Installed packages have exact dependencies 'installedDepends'.
class Package pkg => PackageInstalled pkg where
installedPackageId :: pkg -> InstalledPackageId
installedDepends :: pkg -> [InstalledPackageId]
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.PackageDescription
......@@ -33,6 +35,7 @@ module Distribution.PackageDescription (
-- ** Libraries
Library(..),
ModuleReexport(..),
emptyLibrary,
withLib,
hasLibs,
......@@ -95,12 +98,14 @@ module Distribution.PackageDescription (
knownRepoTypes,
) where
import Data.Binary (Binary)
import Data.Data (Data)
import Data.List (nub, intercalate)
import Data.Maybe (fromMaybe, maybeToList)
import Data.Monoid (Monoid(mempty, mappend))
import Data.Typeable ( Typeable )
import Control.Monad (MonadPlus(mplus))
import GHC.Generics (Generic)
import Text.PrettyPrint as Disp
import qualified Distribution.Compat.ReadP as Parse
import qualified Data.Char as Char (isAlphaNum, isDigit, toLower)
......@@ -109,7 +114,6 @@ import Distribution.Package
( PackageName(PackageName), PackageIdentifier(PackageIdentifier)
, Dependency, Package(..) )
import Distribution.ModuleName ( ModuleName )
import Distribution.ModuleExport ( ModuleExport )
import Distribution.Version
( Version(Version), VersionRange, anyVersion, orLaterVersion
, asVersionIntervals, LowerBound(..) )
......@@ -151,6 +155,17 @@ data PackageDescription
customFieldsPD :: [(String,String)], -- ^Custom fields starting
-- with x-, stored in a
-- simple assoc-list.
-- | YOU PROBABLY DON'T WANT TO USE THIS FIELD. This field is
-- special! Depending on how far along processing the
-- PackageDescription we are, the contents of this field are
-- either nonsense, or the collected dependencies of *all* the
-- components in this package. buildDepends is initialized by
-- 'finalizePackageDescription' and 'flattenPackageDescription';
-- prior to that, dependency info is stored in the 'CondTree'
-- built around a 'GenericPackageDescription'. When this
-- resolution is done, dependency info is written to the inner
-- 'BuildInfo' and this field. This is all horrible, and #2066
-- tracks progress to get rid of this field.
buildDepends :: [Dependency],
-- | The version of the Cabal spec that this package description uses.
-- For historical reasons this is specified with a version range but
......@@ -169,7 +184,9 @@ data PackageDescription
extraTmpFiles :: [FilePath],
extraDocFiles :: [FilePath]
}
deriving (Show, Read, Eq, Typeable, Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary PackageDescription
instance Package PackageDescription where
packageId = package
......@@ -247,7 +264,9 @@ data BuildType
-- be built. Doing it this way rather than just giving a
-- parse error means we get better error messages and allows
-- you to inspect the rest of the package description.
deriving (Show, Read, Eq, Typeable, Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary BuildType
knownBuildTypes :: [BuildType]
knownBuildTypes = [Simple, Configure, Make, Custom]
......@@ -270,11 +289,13 @@ instance Text BuildType where
data Library = Library {
exposedModules :: [ModuleName],
reexportedModules :: [ModuleExport ModuleName],
reexportedModules :: [ModuleReexport],
libExposed :: Bool, -- ^ Is the lib to be exposed by default?
libBuildInfo :: BuildInfo
}
deriving (Show, Eq, Read, Typeable, Data)
deriving (Generic, Show, Eq, Read, Typeable, Data)
instance Binary Library
instance Monoid Library where
mempty = Library {
......@@ -318,6 +339,39 @@ libModules :: Library -> [ModuleName]
libModules lib = exposedModules lib
++ otherModules (libBuildInfo lib)
-- -----------------------------------------------------------------------------
-- Module re-exports
data ModuleReexport = ModuleReexport {
moduleReexportOriginalPackage :: Maybe PackageName,
moduleReexportOriginalName :: ModuleName,
moduleReexportName :: ModuleName
}
deriving (Eq, Generic, Read, Show, Typeable, Data)
instance Binary ModuleReexport
instance Text ModuleReexport where
disp (ModuleReexport mpkgname origname newname) =
maybe Disp.empty (\pkgname -> disp pkgname <> Disp.char ':') mpkgname
<> disp origname
<+> if newname == origname
then Disp.empty
else Disp.text "as" <+> disp newname
parse = do
mpkgname <- Parse.option Nothing $ do
pkgname <- parse
_ <- Parse.char ':'
return (Just pkgname)
origname <- parse
newname <- Parse.option origname $ do
Parse.skipSpaces
_ <- Parse.string "as"
Parse.skipSpaces
parse
return (ModuleReexport mpkgname origname newname)
-- ---------------------------------------------------------------------------
-- The Executable type
......@@ -326,7 +380,9 @@ data Executable = Executable {
modulePath :: FilePath,
buildInfo :: BuildInfo
}
deriving (Show, Read, Eq, Typeable, Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary Executable
instance Monoid Executable where
mempty = Executable {
......@@ -380,7 +436,9 @@ data TestSuite = TestSuite {
-- a better solution is waiting on the next overhaul to the
-- GenericPackageDescription -> PackageDescription resolution process.
}
deriving (Show, Read, Eq, Typeable, Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary TestSuite
-- | The test suite interfaces that are currently defined. Each test suite must
-- specify which interface it supports.
......@@ -406,7 +464,9 @@ data TestSuiteInterface =
-- the given reason (e.g. unknown test type).
--
| TestSuiteUnsupported TestType
deriving (Eq, Read, Show, Typeable, Data)
deriving (Eq, Generic, Read, Show, Typeable, Data)
instance Binary TestSuiteInterface
instance Monoid TestSuite where
mempty = TestSuite {
......@@ -462,7 +522,9 @@ testModules test = (case testInterface test of
data TestType = TestTypeExe Version -- ^ \"type: exitcode-stdio-x.y\"
| TestTypeLib Version -- ^ \"type: detailed-x.y\"
| TestTypeUnknown String Version -- ^ Some unknown test type e.g. \"type: foo\"
deriving (Show, Read, Eq, Typeable, Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary TestType
knownTestTypes :: [TestType]
knownTestTypes = [ TestTypeExe (Version [1,0] [])
......@@ -511,7 +573,9 @@ data Benchmark = Benchmark {
benchmarkEnabled :: Bool
-- TODO: See TODO for 'testEnabled'.
}
deriving (Show, Read, Eq, Typeable, Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary Benchmark
-- | The benchmark interfaces that are currently defined. Each
-- benchmark must specify which interface it supports.
......@@ -533,7 +597,9 @@ data BenchmarkInterface =
-- interfaces for the given reason (e.g. unknown benchmark type).
--
| BenchmarkUnsupported BenchmarkType
deriving (Eq, Read, Show, Typeable, Data)
deriving (Eq, Generic, Read, Show, Typeable, Data)
instance Binary BenchmarkInterface
instance Monoid Benchmark where
mempty = Benchmark {
......@@ -587,7 +653,9 @@ data BenchmarkType = BenchmarkTypeExe Version
-- ^ \"type: exitcode-stdio-x.y\"
| BenchmarkTypeUnknown String Version
-- ^ Some unknown benchmark type e.g. \"type: foo\"
deriving (Show, Read, Eq, Typeable, Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary BenchmarkType
knownBenchmarkTypes :: [BenchmarkType]
knownBenchmarkTypes = [ BenchmarkTypeExe (Version [1,0] []) ]
......@@ -641,7 +709,9 @@ data BuildInfo = BuildInfo {
-- simple assoc-list.
targetBuildDepends :: [Dependency] -- ^ Dependencies specific to a library or executable target
}
deriving (Show,Read,Eq,Typeable,Data)
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary BuildInfo
instance Monoid BuildInfo where
mempty = BuildInfo {
......@@ -815,7 +885,9 @@ data SourceRepo = SourceRepo {
-- given the default is \".\" ie no subdirectory.
repoSubdir :: Maybe FilePath
}
deriving (Eq, Read, Show, Typeable, Data)
deriving (Eq, Generic, Read, Show, Typeable, Data)
instance Binary SourceRepo
-- | What this repo info is for, what it represents.
--
......@@ -831,7 +903,9 @@ data RepoKind =
| RepoThis
| RepoKindUnknown String
deriving (Eq, Ord, Read, Show, Typeable, Data)
deriving (Eq, Generic, Ord, Read, Show, Typeable, Data)
instance Binary RepoKind
-- | An enumeration of common source control systems. The fields used in the
-- 'SourceRepo' depend on the type of repo. The tools and methods used to
......@@ -840,7 +914,9 @@ data RepoKind =
data RepoType = Darcs | Git | SVN | CVS
| Mercurial | GnuArch | Bazaar | Monotone
| OtherRepoType String
deriving (Eq, Ord, Read, Show, Typeable, Data)
deriving (Eq, Generic, Ord, Read, Show, Typeable, Data)
instance Binary RepoType
knownRepoTypes :: [RepoType]
knownRepoTypes = [Darcs, Git, SVN, CVS
......@@ -942,7 +1018,9 @@ data Flag = MkFlag
-- | A 'FlagName' is the name of a user-defined configuration flag
newtype FlagName = FlagName String
deriving (Eq, Ord, Show, Read, Typeable, Data)
deriving (Eq, Generic, Ord, Show, Read, Typeable, Data)
instance Binary FlagName
-- | A 'FlagAssignment' is a total or partial mapping of 'FlagName's to
-- 'Bool' flag values. It represents the flags chosen by the user or
......
......@@ -65,8 +65,6 @@ import Distribution.Version
import Distribution.Package
( PackageName(PackageName), packageName, packageVersion
, Dependency(..), pkgName )
import Distribution.ModuleExport
( ModuleExport(..) )
import Distribution.Text
( display, disp )
......@@ -224,7 +222,7 @@ checkLibrary _pkg lib =
where
moduleDuplicates = dups (libModules lib ++
map exportName (reexportedModules lib))
map moduleReexportName (reexportedModules lib))
checkExecutable :: PackageDescription -> Executable -> [PackageCheck]
checkExecutable pkg exe =
......
......@@ -203,12 +203,11 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
-- Register the library in-place, so exes can depend
-- on internally defined libraries.
pwd <- getCurrentDirectory
let installedPkgInfo =
(inplaceInstalledPackageInfo pwd distPref pkg_descr lib lbi clbi) {
-- The in place registration uses the "-inplace" suffix,
-- not an ABI hash.
IPI.installedPackageId = inplacePackageId (packageId installedPkgInfo)
}
let -- The in place registration uses the "-inplace" suffix, not an ABI hash
ipkgid = inplacePackageId (packageId installedPkgInfo)
installedPkgInfo = inplaceInstalledPackageInfo pwd distPref pkg_descr
ipkgid lib lbi clbi
registerPackage verbosity
installedPkgInfo pkg_descr lbi True -- True meaning in place
(withPackageDB lbi)
......@@ -368,6 +367,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
libClbi = LibComponentLocalBuildInfo
{ componentPackageDeps = componentPackageDeps clbi
, componentLibraries = [LibraryName (testName test)]
, componentModuleReexports = []
}
pkg = pkg_descr {
package = (package pkg_descr) {
......@@ -386,9 +386,8 @@ testSuiteLibV09AsLibAndExe pkg_descr
pkgKey = mkPackageKey (packageKeySupported (compiler lbi))
(package pkg) []
}
ipi = (inplaceInstalledPackageInfo pwd distPref pkg lib lbi libClbi) {
IPI.installedPackageId = inplacePackageId $ packageId ipi
}
ipkgid = inplacePackageId (packageId pkg)
ipi = inplaceInstalledPackageInfo pwd distPref pkg ipkgid lib lbi libClbi
testDir = buildDir lbi </> stubName test
</> stubName test ++ "-tmp"
testLibDep = thisPackageVersion $ package pkg
......
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.Compiler
......@@ -52,9 +54,11 @@ import Distribution.Text (display)
import Language.Haskell.Extension (Language(Haskell98), Extension)
import Control.Monad (liftM)
import Data.Binary (Binary)
import Data.List (nub)
import qualified Data.Map as M (Map, lookup)
import Data.Maybe (catMaybes, isNothing)
import GHC.Generics (Generic)
import System.Directory (canonicalizePath)
data Compiler = Compiler {
......@@ -67,7 +71,9 @@ data Compiler = Compiler {
compilerProperties :: M.Map String String
-- ^ A key-value map for properties not covered by the above fields.
}
deriving (Show, Read)
deriving (Generic, Show, Read)
instance Binary Compiler
showCompilerId :: Compiler -> String
showCompilerId = display . compilerId
......@@ -92,7 +98,9 @@ compilerVersion = (\(CompilerId _ v) -> v) . compilerId
data PackageDB = GlobalPackageDB
| UserPackageDB
| SpecificPackageDB FilePath
deriving (Eq, Ord, Show, Read)
deriving (Eq, Generic, Ord, Show, Read)
instance Binary PackageDB
-- | We typically get packages from several databases, and stack them
-- together. This type lets us be explicit about that stacking. For example
......@@ -142,7 +150,9 @@ absolutePackageDBPath (SpecificPackageDB db) =
data OptimisationLevel = NoOptimisation
| NormalOptimisation
| MaximumOptimisation
deriving (Eq, Show, Read, Enum, Bounded)
deriving (Bounded, Enum, Eq, Generic, Read, Show)
instance Binary OptimisationLevel
flagToOptimisationLevel :: Maybe String -> OptimisationLevel
flagToOptimisationLevel Nothing = NormalOptimisation
......
This diff is collapsed.
......@@ -57,7 +57,7 @@ import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
( InstalledPackageInfo_(..) )
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), ComponentLocalBuildInfo(..)
......@@ -497,14 +497,14 @@ oldLanguageExtensions =
]
-- | Given a single package DB, return all installed packages.
getPackageDBContents :: Verbosity -> PackageDB -> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
getPackageDBContents verbosity packagedb conf = do
pkgss <- getInstalledPackages' verbosity [packagedb] conf
toPackageIndex verbosity pkgss conf
-- | Given a package DB stack, return all installed packages.
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
getInstalledPackages verbosity packagedbs conf = do
checkPackageDbEnvVar
checkPackageDbStack packagedbs
......@@ -526,7 +526,7 @@ getInstalledPackages verbosity packagedbs conf = do
toPackageIndex :: Verbosity
-> [(PackageDB, [InstalledPackageInfo])]
-> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
toPackageIndex verbosity pkgss conf = do
-- On Windows, various fields have $topdir/foo rather than full
-- paths. We need to substitute the right value in so that when
......@@ -1154,7 +1154,8 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
else error "libAbiHash: Can't find an enabled library way"
--
(ghcProg, _) <- requireProgram verbosity ghcProgram (withPrograms lbi)
getProgramInvocationOutput verbosity (ghcInvocation ghcProg comp ghcArgs)
hash <- getProgramInvocationOutput verbosity (ghcInvocation ghcProg comp ghcArgs)
return (takeWhile (not . isSpace) hash)
componentGhcOptions :: Verbosity -> LocalBuildInfo
......
......@@ -14,7 +14,7 @@ module Distribution.Simple.GHC.IPI641 (
) where
import qualified Distribution.InstalledPackageInfo as Current
import qualified Distribution.Package as Current hiding (depends)
import qualified Distribution.Package as Current hiding (depends, installedPackageId)
import Distribution.Text (display)
import Distribution.Simple.GHC.IPI642
......
......@@ -19,7 +19,7 @@ module Distribution.Simple.GHC.IPI642 (
) where
import qualified Distribution.InstalledPackageInfo as Current
import qualified Distribution.Package as Current hiding (depends)
import qualified Distribution.Package as Current hiding (depends, installedPackageId)
import qualified Distribution.License as Current
import Distribution.Version (Version)
......
......@@ -117,7 +117,7 @@ getLanguages verbosity prog = do
-- Other compilers do some kind of a packagedb stack check here. Not sure
-- if we need something like that as well.
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
getInstalledPackages verbosity packagedbs conf =
liftM (PackageIndex.fromList . concat) $ forM packagedbs $ \packagedb ->
do str <-
......
......@@ -38,7 +38,7 @@ import Distribution.Simple.Compiler
, Compiler(..), Flag, languageToFlags, extensionsToFlags
, PackageDB(..), PackageDBStack )
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
import Distribution.Simple.Program
( Program(programFindVersion)
, ProgramConfiguration, userMaybeSpecifyPath
......@@ -180,7 +180,7 @@ hugsLanguageExtensions =
]
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
getInstalledPackages verbosity packagedbs conf = do
homedir <- getHomeDirectory
(hugsProg, _) <- requireProgram verbosity hugsProgram conf
......@@ -191,7 +191,7 @@ getInstalledPackages verbosity packagedbs conf = do
return $! mconcat indexes
where
getIndividualDBPackages :: FilePath -> IO PackageIndex
getIndividualDBPackages :: FilePath -> IO InstalledPackageIndex
getIndividualDBPackages dbdir = do
pkgdirs <- getPackageDbDirs dbdir
pkgs <- sequence [ getInstalledPackage pkgname pkgdir
......
{-# LANGUAGE CPP, ForeignFunctionInterface #-}
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.InstallDirs
......@@ -41,9 +43,11 @@ module Distribution.Simple.InstallDirs (
) where
import Data.Binary (Binary)
import Data.List (isPrefixOf)
import Data.Maybe (fromMaybe)
import Data.Monoid (Monoid(..))
import GHC.Generics (Generic)
import System.Directory (getAppUserDataDirectory)
import System.FilePath ((</>), isPathSeparator, pathSeparator)
import System.FilePath (dropDrive)
......@@ -89,7 +93,9 @@ data InstallDirs dir = InstallDirs {
htmldir :: dir,
haddockdir :: dir,
sysconfdir :: dir
} deriving (Read, Show)
} deriving (Generic, Read, Show)
instance Binary dir => Binary (InstallDirs dir)
instance Functor InstallDirs where
fmap f dirs = InstallDirs {
......@@ -346,12 +352,16 @@ prefixRelativeInstallDirs pkgId pkg_key compilerId platform dirs =
-- | An abstract path, possibly containing variables that need to be
-- substituted for to get a real 'FilePath'.
--
newtype PathTemplate = PathTemplate [PathComponent]
newtype PathTemplate = PathTemplate [PathComponent] deriving (Generic)
instance Binary PathTemplate
data PathComponent =
Ordinary FilePath
| Variable PathTemplateVariable
deriving Eq
deriving (Eq, Generic)
instance Binary PathComponent
data PathTemplateVariable =
PrefixVar -- ^ The @$prefix@ path variable
......@@ -374,7 +384,9 @@ data PathTemplateVariable =
| TestSuiteResultVar -- ^ The result of the test suite being run, eg
-- @pass@, @fail@, or @error@.
| BenchmarkNameVar -- ^ The name of the benchmark being run
deriving Eq
deriving (Eq, Generic)
instance Binary PathTemplateVariable
type PathTemplateEnv = [(PathTemplateVariable, PathTemplate)]
......
......@@ -22,7 +22,7 @@ import Distribution.PackageDescription as PD
import Distribution.InstalledPackageInfo
( emptyInstalledPackageInfo, )
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), ComponentLocalBuildInfo(..) )
......@@ -100,7 +100,7 @@ jhcLanguageExtensions =
]
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
getInstalledPackages verbosity _packageDBs conf = do
-- jhc --list-libraries lists all available libraries.
-- How shall I find out, whether they are global or local
......
......@@ -218,7 +218,7 @@ getExtensions verbosity lhcProg = do
| Just ext <- map readExtension (lines exts) ]
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
getInstalledPackages verbosity packagedbs conf = do
checkPackageDbStack packagedbs
pkgss <- getInstalledPackages' lhcPkg verbosity packagedbs conf
......
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.LocalBuildInfo
......@@ -64,23 +66,28 @@ import Distribution.PackageDescription
( PackageDescription(..), withLib, Library(libBuildInfo), withExe
, Executable(exeName, buildInfo), withTest, TestSuite(..)
, BuildInfo(buildable), Benchmark(..) )
import qualified Distribution.InstalledPackageInfo as Installed
( ModuleReexport(..) )
import Distribution.Package
( PackageId, Package(..), InstalledPackageId(..), PackageKey )
import Distribution.Simple.Compiler
( Compiler(..), PackageDBStack, OptimisationLevel )
import Distribution.Simple.PackageIndex
( PackageIndex )
( InstalledPackageIndex )
import Distribution.Simple.Setup
( ConfigFlags )
import Distribution.Text
( display )
import Distribution.System
( Platform )
import Data.List (nub, find)
import Data.Graph
import Data.Tree (flatten)
import Data.Array ((!))
import Data.Binary (Binary)
import Data.Graph
import Data.List (nub, find)
import Data.Maybe
import Data.Tree (flatten)
import GHC.Generics (Generic)
-- | Data cached after configuration step. See also
-- 'Distribution.Simple.Setup.ConfigFlags'.
......@@ -107,7 +114,7 @@ data LocalBuildInfo = LocalBuildInfo {
componentsConfigs :: [(ComponentName, ComponentLocalBuildInfo, [ComponentName])],
-- ^ All the components to build, ordered by topological sort, and with their dependencies
-- over the intrapackage dependency graph
installedPkgs :: PackageIndex,
installedPkgs :: InstalledPackageIndex,
-- ^ All the info about the installed packages that the
-- current package depends on (directly or indirectly).
pkgDescrFile :: Maybe FilePath,
......@@ -132,7 +139,9 @@ data LocalBuildInfo = LocalBuildInfo {
stripLibs :: Bool, -- ^Whether to strip libraries during install
progPrefix :: PathTemplate, -- ^Prefix to be prepended to installed executables
progSuffix :: PathTemplate -- ^Suffix to be appended to installed executables
} deriving (Read, Show)
} deriving (Generic, Read, Show)
instance Binary LocalBuildInfo
-- | External package dependencies for the package as a whole. This is the
-- union of the individual 'componentPackageDeps', less any internal deps.
......@@ -167,7 +176,9 @@ data ComponentName = CLibName -- currently only a single lib
| CExeName String
| CTestName String
| CBenchName String
deriving (Show, Eq, Ord, Read)
deriving (Eq, Generic, Ord, Read, Show)
instance Binary ComponentName
showComponentName :: ComponentName -> String
showComponentName CLibName = "library"
......@@ -182,7 +193,8 @@ data ComponentLocalBuildInfo
-- satisfied in terms of version ranges. This field fixes those dependencies
-- to the specific versions available on this machine for this compiler.
componentPackageDeps :: [(InstalledPackageId, PackageId)],
componentLibraries :: [LibraryName]
componentLibraries :: [LibraryName],
componentModuleReexports :: [Installed.ModuleReexport]
}
| ExeComponentLocalBuildInfo {
componentPackageDeps :: [(InstalledPackageId, PackageId)]
......@@ -193,7 +205,9 @@ data ComponentLocalBuildInfo
| BenchComponentLocalBuildInfo {
componentPackageDeps :: [(InstalledPackageId, PackageId)]
}
deriving (Read, Show)
deriving (Generic, Read, Show)
instance Binary ComponentLocalBuildInfo
foldComponent :: (Library -> a)
-> (Executable -> a)
......@@ -207,7 +221,9 @@ foldComponent _ _ f _ (CTest tst) = f tst
foldComponent _ _ _ f (CBench bch) = f bch
data LibraryName = LibraryName String
deriving (Read, Show)
deriving (Generic, Read, Show)
instance Binary LibraryName
componentBuildInfo :: Component -> BuildInfo
componentBuildInfo =
......
......@@ -42,7 +42,7 @@ import Distribution.Simple.Compiler
, Flag, languageToFlags, extensionsToFlags
, PackageDB(..), PackageDBStack )
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
import Language.Haskell.Extension
( Language(Haskell98), Extension(..), KnownExtension(..) )
import Distribution.Simple.Program
......@@ -140,7 +140,7 @@ nhcLanguageExtensions =
]
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
-> IO PackageIndex
-> IO InstalledPackageIndex
getInstalledPackages verbosity packagedbs conf = do
homedir <- getHomeDirectory
(nhcProg, _) <- requireProgram verbosity nhcProgram conf
......@@ -151,7 +151,7 @@ getInstalledPackages verbosity packagedbs conf = do
return $! mconcat indexes
where
getIndividualDBPackages :: FilePath -> IO PackageIndex
getIndividualDBPackages :: FilePath -> IO InstalledPackageIndex
getIndividualDBPackages dbdir = do
pkgdirs <- getPackageDbDirs dbdir
pkgs <- sequence [ getInstalledPackage pkgname pkgdir
......
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.PackageIndex
......@@ -12,6 +14,7 @@
--
module Distribution.Simple.PackageIndex (
-- * Package index data type
InstalledPackageIndex,
PackageIndex,
-- * Creating an index
......@@ -32,6 +35,7 @@ module Distribution.Simple.PackageIndex (
-- ** Precise lookups
lookupInstalledPackageId,
lookupSourcePackageId,
lookupPackageId,
lookupPackageName,
lookupDependency,
......@@ -57,47 +61,47 @@ module Distribution.Simple.PackageIndex (
moduleNameIndex,
) where
import Prelude hiding (lookup)
import Control.Exception (assert)
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Tree as Tree
import qualified Data.Graph as Graph
import qualified Data.Array as Array
import Data.Array ((!))
import qualified Data.Array as Array
import Data.Binary (Binary)
import qualified Data.Graph as Graph
import Data.List as List
( null, foldl', sort
, groupBy, sortBy, find, isInfixOf, nubBy, deleteBy, deleteFirstsBy )
import Data.Monoid (Monoid(..))
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe (isNothing, fromMaybe)
import qualified Data.Tree as Tree
import GHC.Generics (Generic)
import Prelude hiding (lookup)
import Distribution.Package
( PackageName(..), PackageId
, Package(..), packageName, packageVersion
, Dependency(Dependency)--, --PackageFixedDeps(..)
, InstalledPackageId(..) )
, InstalledPackageId(..), PackageInstalled(..) )
import Distribution.ModuleName
( ModuleName )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo, installedPackageId )
( InstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as IPI
import Distribution.Version
( Version, withinRange )
import Distribution.Simple.Utils (lowercase, comparing, equating)
import Distribution.ModuleExport
( ModuleExport(..) )
-- | The collection of information about packages from one or more 'PackageDB's.
-- These packages generally should have an instance of 'PackageInstalled'
--
-- Packages are uniquely identified in by their 'InstalledPackageId', they can
-- also be efficiently looked up by package name or by name and version.
--
data PackageIndex = PackageIndex
data PackageIndex a = PackageIndex
-- The primary index. Each InstalledPackageInfo record is uniquely identified
-- by its InstalledPackageId.
--
!(Map InstalledPackageId InstalledPackageInfo)
!(Map InstalledPackageId a)
-- This auxiliary index maps package names (case-sensitively) to all the
-- versions and instances of that package. This allows us to find all
......@@ -110,18 +114,24 @@ data PackageIndex = PackageIndex
--
-- FIXME: Clarify what "preference order" means. Check that this invariant is
-- preserved. See #1463 for discussion.
!(Map PackageName (Map Version [InstalledPackageInfo]))
!(Map PackageName (Map Version [a]))
deriving (Generic, Show, Read)
instance Binary a => Binary (PackageIndex a)
deriving (Show, Read)
-- | The default package index which contains 'InstalledPackageInfo'. Normally
-- use this.
type InstalledPackageIndex = PackageIndex InstalledPackageInfo
instance Monoid PackageIndex where
instance PackageInstalled a => Monoid (PackageIndex a) where
mempty = PackageIndex Map.empty Map.empty
mappend = merge
--save one mappend with empty in the common case:
mconcat [] = mempty
mconcat xs = foldr1 mappend xs
invariant :: PackageIndex -> Bool
invariant :: PackageInstalled a => PackageIndex a -> Bool
invariant (PackageIndex pids pnames) =
map installedPackageId (Map.elems pids)
== sort
......@@ -142,9 +152,10 @@ invariant (PackageIndex pids pnames) =
-- * Internal helpers
--
mkPackageIndex :: Map InstalledPackageId InstalledPackageInfo
-> Map PackageName (Map Version [InstalledPackageInfo])
-> PackageIndex
mkPackageIndex :: PackageInstalled a
=> Map InstalledPackageId a
-> Map PackageName (Map Version [a])
-> PackageIndex a
mkPackageIndex pids pnames = assert (invariant index) index
where index = PackageIndex pids pnames
......@@ -158,7 +169,7 @@ mkPackageIndex pids pnames = assert (invariant index) index
-- If there are duplicates by 'InstalledPackageId' then later ones mask earlier
-- ones.
--
fromList :: [InstalledPackageInfo] -> PackageIndex
fromList :: PackageInstalled a => [a] -> PackageIndex a
fromList pkgs = mkPackageIndex pids pnames
where
pids = Map.fromList [ (installedPackageId pkg, pkg) | pkg <- pkgs ]
......@@ -190,7 +201,7 @@ fromList pkgs = mkPackageIndex pids pnames
-- result when we do a lookup by source 'PackageId'. This is the mechanism we
-- use to prefer user packages over global packages.
--
merge :: PackageIndex -> PackageIndex -> PackageIndex
merge :: PackageInstalled a => PackageIndex a -> PackageIndex a -> PackageIndex a
merge (PackageIndex pids1 pnames1) (PackageIndex pids2 pnames2) =
mkPackageIndex (Map.union pids1 pids2)
(Map.unionWith (Map.unionWith mergeBuckets) pnames1 pnames2)
......@@ -206,7 +217,7 @@ merge (PackageIndex pids1 pnames1) (PackageIndex pids2 pnames2) =
-- This is equivalent to (but slightly quicker than) using 'mappend' or
-- 'merge' with a singleton index.
--
insert :: InstalledPackageInfo -> PackageIndex -> PackageIndex
insert :: PackageInstalled a => a -> PackageIndex a -> PackageIndex a
insert pkg (PackageIndex pids pnames) =
mkPackageIndex pids' pnames'
......@@ -228,7 +239,7 @@ insert pkg (PackageIndex pids pnames) =
-- | Removes a single installed package from the index.
--
deleteInstalledPackageId :: InstalledPackageId -> PackageIndex -> PackageIndex
deleteInstalledPackageId :: PackageInstalled a => InstalledPackageId -> PackageIndex a -> PackageIndex a
deleteInstalledPackageId ipkgid original@(PackageIndex pids pnames) =
case Map.updateLookupWithKey (\_ _ -> Nothing) ipkgid pids of
(Nothing, _) -> original
......@@ -250,7 +261,7 @@ deleteInstalledPackageId ipkgid original@(PackageIndex pids pnames) =
-- | Removes all packages with this source 'PackageId' from the index.
--
deleteSourcePackageId :: PackageId -> PackageIndex -> PackageIndex
deleteSourcePackageId :: PackageInstalled a => PackageId -> PackageIndex a -> PackageIndex a
deleteSourcePackageId pkgid original@(PackageIndex pids pnames) =
case Map.lookup (packageName pkgid) pnames of
Nothing -> original
......@@ -270,7 +281,7 @@ deleteSourcePackageId pkgid original@(PackageIndex pids pnames) =
-- | Removes all packages with this (case-sensitive) name from the index.
--
deletePackageName :: PackageName -> PackageIndex -> PackageIndex
deletePackageName :: PackageInstalled a => PackageName -> PackageIndex a -> PackageIndex a
deletePackageName name original@(PackageIndex pids pnames) =
case Map.lookup name pnames of
Nothing -> original
......@@ -293,14 +304,14 @@ deleteDependency (Dependency name verstionRange) =
-- | Get all the packages from the index.
--
allPackages :: PackageIndex -> [InstalledPackageInfo]
allPackages :: PackageIndex a -> [a]
allPackages (PackageIndex pids _) = Map.elems pids
-- | Get all the packages from the index.
--
-- They are grouped by package name (case-sensitively).
--
allPackagesByName ::