Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
b55fc485
Commit
b55fc485
authored
Feb 22, 2008
by
Duncan Coutts
Browse files
Move Package class to Distribution.Package
parent
f08ff028
Changes
6
Hide whitespace changes
Inline
Side-by-side
Distribution/InstalledPackageInfo.hs
View file @
b55fc485
...
...
@@ -63,6 +63,8 @@ import Distribution.ParseUtils (
import
Distribution.License
(
License
(
..
)
)
import
Distribution.Package
(
PackageIdentifier
(
..
),
showPackageId
,
parsePackageId
)
import
qualified
Distribution.Package
as
Package
(
Package
(
..
),
PackageFixedDeps
(
..
)
)
import
Distribution.Version
(
Version
(
..
),
showVersion
)
import
Distribution.Compat.ReadP
as
ReadP
...
...
@@ -107,6 +109,11 @@ data InstalledPackageInfo_ m
}
deriving
(
Read
,
Show
)
instance
Package
.
Package
(
InstalledPackageInfo_
str
)
where
packageId
=
package
instance
Package
.
PackageFixedDeps
(
InstalledPackageInfo_
str
)
where
depends
=
depends
type
InstalledPackageInfo
=
InstalledPackageInfo_
String
emptyInstalledPackageInfo
::
InstalledPackageInfo_
m
...
...
Distribution/Package.hs
View file @
b55fc485
...
...
@@ -40,8 +40,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module
Distribution.Package
(
-- * Package ids
PackageIdentifier
(
..
),
showPackageId
,
parsePackageId
,
parsePackageName
,
-- * Package classes
Package
(
..
),
PackageFixedDeps
(
..
),
)
where
import
Distribution.Version
...
...
@@ -78,3 +83,25 @@ parsePackageId = do
n
<-
parsePackageName
v
<-
(
ReadP
.
char
'-'
>>
parseVersion
)
<++
return
(
Version
[]
[]
)
return
PackageIdentifier
{
pkgName
=
n
,
pkgVersion
=
v
}
-- | Class of things that can be identified by a 'PackageIdentifier'
--
-- Types in this class are all notions of a package. This allows us to have
-- different types for the different phases that packages go though, from
-- simple name\/id, package description, configured or installed packages.
--
class
Package
pkg
where
packageId
::
pkg
->
PackageIdentifier
instance
Package
PackageIdentifier
where
packageId
=
id
-- | Subclass of packages that have specific versioned dependencies.
--
-- So for example a not-yet-configured package has dependencies on version
-- ranges, not specific versions. A configured or an already installed package
-- depends on exact versions. Some operations or data structures (like
-- dependency graphs) only make sense on this subclass of package types.
--
class
Package
pkg
=>
PackageFixedDeps
pkg
where
depends
::
pkg
->
[
PackageIdentifier
]
Distribution/PackageDescription.hs
View file @
b55fc485
...
...
@@ -80,7 +80,7 @@ import Data.List (nub)
import
Data.Monoid
(
Monoid
(
mempty
,
mappend
))
import
Text.PrettyPrint.HughesPJ
import
Distribution.Package
(
PackageIdentifier
(
Package
Identifier
))
import
Distribution.Package
(
PackageIdentifier
(
..
),
Package
(
..
))
import
Distribution.Version
(
Version
(
Version
),
VersionRange
(
AnyVersion
))
import
Distribution.License
(
License
(
AllRightsReserved
))
import
Distribution.Version
(
Dependency
,
showVersionRange
)
...
...
@@ -128,6 +128,9 @@ data PackageDescription
}
deriving
(
Show
,
Read
,
Eq
)
instance
Package
PackageDescription
where
packageId
=
package
emptyPackageDescription
::
PackageDescription
emptyPackageDescription
=
PackageDescription
{
package
=
PackageIdentifier
""
(
Version
[]
[]
),
...
...
@@ -412,6 +415,9 @@ data GenericPackageDescription =
}
deriving
(
Show
)
instance
Package
GenericPackageDescription
where
packageId
=
packageId
.
packageDescription
{-
-- XXX: I think we really want a PPrint or Pretty or ShowPretty class.
instance Show GenericPackageDescription where
...
...
Distribution/PackageDescription/Configuration.hs
View file @
b55fc485
...
...
@@ -52,11 +52,12 @@ module Distribution.PackageDescription.Configuration (
freeVars
,
)
where
import
Distribution.Package
(
Package
)
import
Distribution.PackageDescription
(
GenericPackageDescription
(
..
),
PackageDescription
(
..
)
,
Library
(
..
),
Executable
(
..
),
BuildInfo
(
..
)
,
Flag
(
..
),
CondTree
(
..
),
ConfVar
(
..
),
ConfFlag
(
..
),
Condition
(
..
)
)
import
Distribution.Simple.PackageIndex
(
PackageIndex
,
Package
)
import
Distribution.Simple.PackageIndex
(
PackageIndex
)
import
qualified
Distribution.Simple.PackageIndex
as
PackageIndex
import
Distribution.Version
(
Version
(
..
),
Dependency
(
..
),
VersionRange
(
..
)
...
...
Distribution/Simple/Configure.hs
View file @
b55fc485
...
...
@@ -58,13 +58,13 @@ import Distribution.Simple.Compiler
(
CompilerFlavor
(
..
),
Compiler
(
..
),
compilerVersion
,
showCompilerId
,
unsupportedExtensions
,
PackageDB
(
..
)
)
import
Distribution.Package
(
PackageIdentifier
(
..
),
showPackageId
)
(
PackageIdentifier
(
..
),
showPackageId
,
Package
(
..
)
)
import
Distribution.InstalledPackageInfo
(
InstalledPackageInfo
,
emptyInstalledPackageInfo
)
import
qualified
Distribution.InstalledPackageInfo
as
InstalledPackageInfo
(
InstalledPackageInfo_
(
package
,
depends
)
)
import
qualified
Distribution.Simple.PackageIndex
as
PackageIndex
import
Distribution.Simple.PackageIndex
(
PackageIndex
,
Package
(
packageId
)
)
import
Distribution.Simple.PackageIndex
(
PackageIndex
)
import
Distribution.PackageDescription
as
PD
(
PackageDescription
(
..
),
GenericPackageDescription
(
..
)
,
Library
(
..
),
hasLibs
,
Executable
(
..
),
BuildInfo
(
..
)
...
...
@@ -199,7 +199,7 @@ configure (pkg_descr0, pbi) cfg
=
do
let
verbosity
=
fromFlag
(
configVerbose
cfg
)
setupMessage
verbosity
"Configuring"
(
package
(
either
packageDescription
id
pkg_descr0
))
(
package
Id
(
either
packageDescription
id
pkg_descr0
))
createDirectoryIfMissingVerbose
(
lessVerbose
verbosity
)
True
distPref
...
...
@@ -262,7 +262,7 @@ configure (pkg_descr0, pbi) cfg
++
" packages
\n
they depend on are missing. These broken "
++
"packages must be rebuilt
\n
before they can be used.
\n
"
++
unlines
[
"package "
++
showPackageId
(
InstalledPackageInfo
.
package
pkg
)
++
showPackageId
(
package
Id
pkg
)
++
" is broken due to missing package "
++
intercalate
", "
(
map
showPackageId
deps
)
|
(
pkg
,
deps
)
<-
broken
]
...
...
Distribution/Simple/PackageIndex.hs
View file @
b55fc485
...
...
@@ -13,10 +13,6 @@
-- An index of packages.
-----------------------------------------------------------------------------
module
Distribution.Simple.PackageIndex
(
-- * Package classes
Package
(
..
),
PackageFixedDeps
(
..
),
-- * Package index data type
PackageIndex
,
...
...
@@ -55,49 +51,11 @@ import Data.List (nubBy, group, sort, groupBy, sortBy, find)
import
Data.Monoid
(
Monoid
(
..
))
import
Data.Maybe
(
isNothing
)
import
Distribution.Package
(
PackageIdentifier
(
..
))
import
Distribution.InstalledPackageInfo
(
InstalledPackageInfo_
)
import
qualified
Distribution.InstalledPackageInfo
as
InstalledPackageInfo
(
InstalledPackageInfo_
(
..
)
)
import
Distribution.PackageDescription
(
PackageDescription
,
GenericPackageDescription
)
import
qualified
Distribution.PackageDescription
as
PackageDescription
(
PackageDescription
(
..
),
GenericPackageDescription
(
packageDescription
)
)
import
Distribution.Package
(
PackageIdentifier
(
..
),
Package
(
..
),
PackageFixedDeps
(
..
)
)
import
Distribution.Version
(
Version
,
Dependency
(
Dependency
),
withinRange
)
import
Distribution.Simple.Utils
(
lowercase
,
equating
,
comparing
,
isInfixOf
)
-- | Class of things that can be identified by a 'PackageIdentifier'
--
-- Types in this class are all notions of a package. This allows us to have
-- different types for the different phases that packages go though, from
-- simple name\/id, package description, configured or installed packages.
--
class
Package
pkg
where
packageId
::
pkg
->
PackageIdentifier
instance
Package
PackageIdentifier
where
packageId
=
id
instance
Package
(
InstalledPackageInfo_
str
)
where
packageId
=
InstalledPackageInfo
.
package
instance
Package
PackageDescription
where
packageId
=
PackageDescription
.
package
instance
Package
GenericPackageDescription
where
packageId
=
packageId
.
PackageDescription
.
packageDescription
-- | Subclass of packages that have specific versioned dependencies.
--
-- So for example a not-yet-configured package has dependencies on version
-- ranges, not specific versions. A configured or an already installed package
-- depends on exact versions. Some operations or data structures (like
-- dependency graphs) only make sense on this subclass of package types.
--
class
Package
pkg
=>
PackageFixedDeps
pkg
where
depends
::
pkg
->
[
PackageIdentifier
]
instance
PackageFixedDeps
(
InstalledPackageInfo_
str
)
where
depends
=
InstalledPackageInfo
.
depends
-- | The collection of information about packages from one or more 'PackageDB's.
--
-- It can be searched effeciently by package name and version.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment