Commit 7146dfe7 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Add thisPackageVersion and notThisPackageVersion

Util functions for makeing dependencies from package identifiers.
thisPackageVersion    (foo-1.0) = foo ==1.0
notThisPackageVersion (foo-1.0) = foo /=1.0
The latter is handy as a constraint in dependency resolution.
parent 2e092600
......@@ -46,13 +46,16 @@ module Distribution.Package (
-- * Package dependencies
Dependency(..),
thisPackageVersion,
notThisPackageVersion,
-- * Package classes
Package(..), packageName, packageVersion,
PackageFixedDeps(..),
) where
import Distribution.Version (Version(..), VersionRange(AnyVersion))
import Distribution.Version
( Version(..), VersionRange(AnyVersion,ThisVersion), notThisVersion )
import Distribution.Text (Text(..))
import qualified Distribution.Compat.ReadP as Parse
......@@ -106,6 +109,14 @@ instance Text Dependency where
Parse.skipSpaces
return (Dependency name ver)
thisPackageVersion :: PackageIdentifier -> Dependency
thisPackageVersion (PackageIdentifier n v) =
Dependency n (ThisVersion v)
notThisPackageVersion :: PackageIdentifier -> Dependency
notThisPackageVersion (PackageIdentifier n v) =
Dependency n (notThisVersion 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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment