Commit 66bb76be authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Add Text instances for Version and VersionRange

The instance for Version is in the Text module itself because the
Version type is defined in base. This avoids an orphan instance.
parent 86ac8140
......@@ -52,10 +52,11 @@ module Distribution.Compiler (
showCompilerId,
) where
import Distribution.Version (Version(..), showVersion)
import Distribution.Version (Version(..))
import qualified System.Info (compilerName)
import qualified Data.Char as Char (toLower)
import Distribution.Text (display)
data CompilerFlavor = GHC | NHC | YHC | Hugs | HBC | Helium | JHC
| OtherCompiler String
......@@ -95,7 +96,7 @@ data CompilerId = CompilerId CompilerFlavor Version
showCompilerId :: CompilerId -> String
showCompilerId (CompilerId f (Version [] _)) = showCompilerFlavor f
showCompilerId (CompilerId f v) = showCompilerFlavor f ++ '-': showVersion v
showCompilerId (CompilerId f v) = showCompilerFlavor f ++ '-': display v
lowercase :: String -> String
lowercase = map Char.toLower
......@@ -66,7 +66,10 @@ import Distribution.Package
, showPackageId, parsePackageId )
import qualified Distribution.Package as Package
( Package(..), PackageFixedDeps(..) )
import Distribution.Version ( Version(..), showVersion )
import Distribution.Version
( Version(..) )
import Distribution.Text
( Text(disp) )
import qualified Distribution.Compat.ReadP as ReadP
import Control.Monad ( foldM )
......@@ -200,7 +203,7 @@ basicFieldDescrs =
text parsePackageNameQ
packageName (\name pkg -> pkg{package=(package pkg){pkgName=name}})
, simpleField "version"
(text . showVersion) parseOptVersion
disp parseOptVersion
packageVersion (\ver pkg -> pkg{package=(package pkg){pkgVersion=ver}})
, simpleField "license"
(text . show) parseLicenseQ
......@@ -237,7 +240,7 @@ parseFreeText = ReadP.munch (const True)
installedFieldDescrs :: [FieldDescr InstalledPackageInfo]
installedFieldDescrs = [
simpleField "exposed"
(text.show) parseReadS
disp parseReadS
exposed (\val pkg -> pkg{exposed=val})
, listField "exposed-modules"
text parseModuleNameQ
......
......@@ -91,7 +91,10 @@ import Distribution.Simple.Command
import Distribution.Simple.Utils (die, rawSystemExit, cabalVersion)
import Distribution.License (License(..))
import Distribution.Version (Version(..), showVersion)
import Distribution.Version
( Version(..) )
import Distribution.Text
( display )
import System.Environment (getArgs, getProgName)
import Data.List (intersperse)
......@@ -128,9 +131,9 @@ defaultMainHelper args =
printErrors errs = do
putStr (concat (intersperse "\n" errs))
exitWith (ExitFailure 1)
printNumericVersion = putStrLn $ showVersion cabalVersion
printNumericVersion = putStrLn $ display cabalVersion
printVersion = putStrLn $ "Cabal library version "
++ showVersion cabalVersion
++ display cabalVersion
progs = defaultProgramConfiguration
commands =
......
......@@ -54,6 +54,8 @@ module Distribution.Package (
) where
import Distribution.Version
import Distribution.Text
( Text(..), display )
import Distribution.Compat.ReadP as ReadP
import qualified Text.PrettyPrint as Pretty
import Text.PrettyPrint ((<+>))
......@@ -72,7 +74,7 @@ data PackageIdentifier
showPackageId :: PackageIdentifier -> String
showPackageId (PackageIdentifier n (Version [] _)) = n -- if no version, don't show version.
showPackageId pkgid =
pkgName pkgid ++ '-': showVersion (packageVersion pkgid)
pkgName pkgid ++ '-': display (packageVersion pkgid)
parsePackageName :: ReadP r String
parsePackageName = do ns <- sepBy1 component (char '-')
......@@ -87,7 +89,7 @@ parsePackageName = do ns <- sepBy1 component (char '-')
parsePackageId :: ReadP r PackageIdentifier
parsePackageId = do
n <- parsePackageName
v <- (ReadP.char '-' >> parseVersion) <++ return (Version [] [])
v <- (ReadP.char '-' >> parse) <++ return (Version [] [])
return PackageIdentifier{pkgName=n,pkgVersion=v}
-- ------------------------------------------------------------
......@@ -99,12 +101,12 @@ data Dependency = Dependency String VersionRange
showDependency :: Dependency -> Pretty.Doc
showDependency (Dependency name ver) =
Pretty.text name <+> Pretty.text (showVersionRange ver)
Pretty.text name <+> disp ver
parseDependency :: ReadP r Dependency
parseDependency = do name <- parsePackageName
skipSpaces
ver <- parseVersionRange <++ return AnyVersion
ver <- parse <++ return AnyVersion
skipSpaces
return $ Dependency name ver
......
......@@ -83,9 +83,10 @@ import Distribution.Package
( PackageIdentifier(PackageIdentifier), Dependency, Package(..) )
import Distribution.Version (Version(Version), VersionRange(AnyVersion))
import Distribution.License (License(AllRightsReserved))
import Distribution.Version (showVersionRange)
import Distribution.Compiler (CompilerFlavor, showCompilerFlavor)
import Distribution.System (OS, showOS, Arch, showArch)
import Distribution.Text
( display )
import Distribution.Simple.Utils (currentDir)
import Language.Haskell.Extension (Extension)
......@@ -469,7 +470,7 @@ instance Show ConfVar where
show (Arch arch) = "arch(" ++ showArch arch ++ ")"
show (Flag (ConfFlag f)) = "flag(" ++ f ++ ")"
show (Impl c v) = "impl(" ++ showCompilerFlavor c
++ " " ++ showVersionRange v ++ ")"
++ " " ++ display v ++ ")"
-- | A boolean expression parameterized over the variable type used.
data Condition c = Var c
......
......@@ -56,9 +56,12 @@ import Distribution.Compiler(CompilerFlavor(..))
import Distribution.License (License(..))
import Distribution.Simple.Utils (cabalVersion, intercalate)
import Distribution.Version (Version(..), withinRange, showVersionRange)
import Distribution.Version
( Version(..), withinRange )
import Distribution.Package
( packageName, packageVersion )
import Distribution.Text
( display )
import Language.Haskell.Extension (Extension(..))
import System.FilePath (takeExtension, isRelative, splitDirectories, (</>))
......@@ -152,7 +155,7 @@ checkSanity pkg =
check (not $ cabalVersion `withinRange` requiredCabalVersion) $
PackageBuildImpossible $
"This package requires Cabal version: "
++ showVersionRange requiredCabalVersion
++ display requiredCabalVersion
]
where requiredCabalVersion = descCabalVersion pkg
......
......@@ -56,12 +56,14 @@ import Distribution.PackageDescription
import Distribution.Simple.PackageIndex (PackageIndex)
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Version
( Version(..), VersionRange(..), withinRange, parseVersionRange )
( Version(..), VersionRange(..), withinRange )
import Distribution.Compiler (CompilerFlavor, readCompilerFlavor)
import Distribution.System
( OS, readOS, Arch, readArch )
import Distribution.Simple.Utils (currentDir)
import Distribution.Text
( Text(parse) )
import Distribution.Compat.ReadP as ReadP hiding ( char )
import qualified Distribution.Compat.ReadP as ReadP ( char )
......@@ -161,7 +163,7 @@ parseCondition = condOr
oper s = sp >> string s >> sp
sp = skipSpaces
implIdent = do i <- ident
vr <- sp >> option AnyVersion parseVersionRange
vr <- sp >> option AnyVersion parse
return $ Impl (readCompilerFlavor i) vr
------------------------------------------------------------------------------
......
......@@ -76,8 +76,7 @@ import Distribution.Package
, parsePackageName
, Dependency(..), showDependency, parseDependency )
import Distribution.Version
( showVersion, parseVersion
, showVersionRange, parseVersionRange, isAnyVersion )
( isAnyVersion )
import Distribution.Verbosity (Verbosity)
import Distribution.Compiler (CompilerFlavor(..))
import Distribution.PackageDescription.Configuration (parseCondition, freeVars)
......@@ -94,10 +93,10 @@ pkgDescrFieldDescrs =
text parsePackageName
packageName (\name pkg -> pkg{package=(package pkg){pkgName=name}})
, simpleField "version"
(text . showVersion) parseVersion
disp parse
packageVersion (\ver pkg -> pkg{package=(package pkg){pkgVersion=ver}})
, simpleField "cabal-version"
(text . showVersionRange) parseVersionRange
disp parse
descCabalVersion (\v pkg -> pkg{descCabalVersion=v})
, simpleField "build-type"
(text . maybe "" show) (fmap Just parseReadSQ)
......
......@@ -66,6 +66,8 @@ import Distribution.Version
import Distribution.Package ( parsePackageName, Dependency(..) )
import Distribution.Compat.ReadP as ReadP hiding (get)
import Distribution.ReadE
import Distribution.Text
( Text(..) )
import Distribution.Simple.Utils (intercalate)
import Language.Haskell.Extension (Extension)
......@@ -537,18 +539,18 @@ parsePackageNameQ :: ReadP r String
parsePackageNameQ = parseQuoted parsePackageName <++ parsePackageName
parseVersionRangeQ :: ReadP r VersionRange
parseVersionRangeQ = parseQuoted parseVersionRange <++ parseVersionRange
parseVersionRangeQ = parseQuoted parse <++ parse
parseOptVersion :: ReadP r Version
parseOptVersion = parseQuoted ver <++ ver
where ver = parseVersion <++ return noVersion
where ver = parse <++ return noVersion
noVersion = Version{ versionBranch=[], versionTags=[] }
parseTestedWithQ :: ReadP r (CompilerFlavor,VersionRange)
parseTestedWithQ = parseQuoted tw <++ tw
where tw = do compiler <- parseReadS
skipSpaces
version <- parseVersionRange <++ return AnyVersion
version <- parse <++ return AnyVersion
skipSpaces
return (compiler,version)
......@@ -604,7 +606,7 @@ showToken str
where dodgy c = isSpace c || c == ','
showTestedWith :: (CompilerFlavor,VersionRange) -> Doc
showTestedWith (compiler,version) = text (show compiler ++ " " ++ showVersionRange version)
showTestedWith (compiler, version) = text (show compiler) <+> disp version
-- | Pretty-print free-format text, ensuring that it is vertically aligned,
-- and with blank lines replaced by dots for correct re-parsing.
......
......@@ -108,6 +108,8 @@ import Distribution.Verbosity
import Language.Haskell.Extension
import Distribution.Version
import Distribution.License
import Distribution.Text
( display )
-- Base
import System.Environment(getArgs,getProgName)
......@@ -166,9 +168,9 @@ defaultMainHelper hooks args =
printErrors errs = do
putStr (concat (intersperse "\n" errs))
exitWith (ExitFailure 1)
printNumericVersion = putStrLn $ showVersion cabalVersion
printNumericVersion = putStrLn $ display cabalVersion
printVersion = putStrLn $ "Cabal library version "
++ showVersion cabalVersion
++ display cabalVersion
progs = allPrograms hooks
commands =
......
......@@ -68,7 +68,8 @@ import Distribution.Compiler
( CompilerId(..), showCompilerFlavor )
import Distribution.PackageDescription (PackageDescription)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(buildDir))
import Distribution.Version (showVersion)
import Distribution.Text
( display )
import Distribution.System (OS(..), buildOS)
-- ---------------------------------------------------------------------------
......@@ -118,7 +119,7 @@ mkSharedLibName :: PackageIdentifier -> CompilerId -> String
mkSharedLibName lib (CompilerId compilerFlavor compilerVersion)
= "libHS" ++ showPackageId lib ++ "-" ++ comp <.> dllExtension
where comp = showCompilerFlavor compilerFlavor
++ showVersion compilerVersion
++ display compilerVersion
-- ------------------------------------------------------------
-- * Platform file extensions
......
......@@ -101,8 +101,7 @@ import Distribution.Simple.Register
import Distribution.System
( OS(..), buildOS, buildArch )
import Distribution.Version
( Version(..), VersionRange(..), showVersion, readVersion
, showVersionRange, orLaterVersion, withinRange )
( Version(..), VersionRange(..), orLaterVersion, withinRange )
import Distribution.Verbosity
( Verbosity, lessVerbose )
......@@ -131,6 +130,8 @@ import qualified System.Info
( compilerName, compilerVersion )
import System.IO
( hPutStrLn, stderr, hGetContents, openFile, hClose, IOMode(ReadMode) )
import Distribution.Text
( display, simpleParse )
import Text.PrettyPrint.HughesPJ
( comma, punctuate, render, nest, sep )
......@@ -481,7 +482,7 @@ reportProgram verbosity prog (Just configuredProg)
UserSpecified p -> " given by user at: " ++ p
version = case programVersion configuredProg of
Nothing -> ""
Just v -> " version " ++ showVersion v
Just v -> " version " ++ display v
hackageUrl :: String
hackageUrl = "http://hackage.haskell.org/cgi-bin/hackage-scripts/package/"
......@@ -491,12 +492,12 @@ configDependency :: Verbosity -> PackageIndex InstalledPackageInfo -> Dependency
configDependency verbosity index dep@(Dependency pkgname vrange) =
case PackageIndex.lookupDependency index dep of
[] -> die $ "cannot satisfy dependency "
++ pkgname ++ showVersionRange vrange ++ "\n"
++ pkgname ++ display vrange ++ "\n"
++ "Perhaps you need to download and install it from\n"
++ hackageUrl ++ pkgname ++ "?"
pkgs -> do let pkgid = maximumBy (comparing packageVersion) (map packageId pkgs)
info verbosity $ "Dependency " ++ pkgname
++ showVersionRange vrange
++ display vrange
++ ": using " ++ showPackageId pkgid
return pkgid
......@@ -547,7 +548,7 @@ configurePkgconfigPackages verbosity pkg_descr conf
requirePkg (Dependency pkg range) = do
version <- pkgconfig ["--modversion", pkg]
`Exception.catch` \_ -> die notFound
case readVersion version of
case simpleParse version of
Nothing -> die "parsing output of pkg-config --modversion failed"
Just v | not (withinRange v range) -> die (badVersion v)
| otherwise -> info verbosity (depSatisfied v)
......@@ -556,13 +557,13 @@ configurePkgconfigPackages verbosity pkg_descr conf
++ " is required but it could not be found."
badVersion v = "The pkg-config package " ++ pkg ++ versionRequirement
++ " is required but the version installed on the"
++ " system is version " ++ showVersion v
depSatisfied v = "Dependency " ++ pkg ++ showVersionRange range
++ ": using version " ++ showVersion v
++ " system is version " ++ display v
depSatisfied v = "Dependency " ++ pkg ++ display range
++ ": using version " ++ display v
versionRequirement
| range == AnyVersion = ""
| otherwise = " version " ++ showVersionRange range
| otherwise = " version " ++ display range
updateLibrary Nothing = return Nothing
updateLibrary (Just lib) = do
......
......@@ -77,11 +77,13 @@ import Distribution.Simple.Program
import Distribution.Simple.Compiler
( CompilerFlavor(..), CompilerId(..), Compiler(..), compilerVersion
, OptimisationLevel(..), PackageDB(..), Flag, extensionsToFlags )
import Distribution.Version ( Version(..), showVersion,
VersionRange(..), orLaterVersion )
import Distribution.Version
( Version(..), VersionRange(..), orLaterVersion )
import Distribution.System
( OS(..), buildOS )
import Distribution.Verbosity
import Distribution.Text
( display )
import Language.Haskell.Extension (Extension(..))
import Control.Monad ( unless, when )
......@@ -121,8 +123,8 @@ configure verbosity hcPath hcPkgPath conf = do
when (ghcVersion /= ghcPkgVersion) $ die $
"Version mismatch between ghc and ghc-pkg: "
++ programPath ghcProg ++ " is version " ++ showVersion ghcVersion ++ " "
++ programPath ghcPkgProg ++ " is version " ++ showVersion ghcPkgVersion
++ programPath ghcProg ++ " is version " ++ display ghcVersion ++ " "
++ programPath ghcPkgProg ++ " is version " ++ display ghcPkgVersion
-- finding ghc's local ld is a bit tricky as it's not on the path:
let ldProgram' = case buildOS of
......@@ -649,7 +651,7 @@ makefile pkg_descr lbi flags = do
let decls = [
("modules", unwords (exposedModules lib ++ otherModules bi)),
("GHC", programPath ghcProg),
("GHC_VERSION", (showVersion (compilerVersion (compiler lbi)))),
("GHC_VERSION", (display (compilerVersion (compiler lbi)))),
("WAYS", (if withProfLib lbi then "p " else "") ++ (if withSharedLib lbi then "dyn" else "")),
("odir", builddir),
("srcdir", case hsSourceDirs bi of
......
......@@ -78,6 +78,8 @@ import Distribution.Simple.Utils
( die, warn, notice, intercalate, setupMessage
, createDirectoryIfMissingVerbose, withTempFile
, findFileWithExtension, findFile, dotToSep )
import Distribution.Text
( simpleParse )
import Distribution.Verbosity
import Language.Haskell.Extension
......@@ -161,7 +163,7 @@ haddock pkg_descr lbi suffixes flags = do
when isVersion2 $ do
strHadGhcVers <- rawSystemProgramStdout verbosity confHaddock ["--ghc-version"]
let mHadGhcVers = readVersion strHadGhcVers
let mHadGhcVers = simpleParse strHadGhcVers
when (mHadGhcVers == Nothing) $ die "Could not get GHC version from Haddock"
when (fromJust mHadGhcVers /= compilerVersion comp) $
die "Haddock's internal GHC version must match the configured GHC version"
......
......@@ -76,11 +76,12 @@ import System.FilePath (dropDrive)
import Distribution.Package
( PackageIdentifier, packageName, packageVersion, showPackageId )
import Distribution.Version (showVersion)
import Distribution.System
( OS(..), buildOS )
import Distribution.Compiler
( CompilerId, showCompilerId, CompilerFlavor(..) )
import Distribution.Text
( display )
#if mingw32_HOST_OS || mingw32_TARGET_OS
import Foreign
......@@ -408,7 +409,7 @@ initialPathTemplateEnv :: PackageIdentifier -> CompilerId
initialPathTemplateEnv pkgId compilerId =
map (\(v,s) -> (v, PathTemplate [Ordinary s]))
[(PkgNameVar, packageName pkgId)
,(PkgVerVar, showVersion (packageVersion pkgId))
,(PkgVerVar, display (packageVersion pkgId))
,(PkgIdVar, showPackageId pkgId)
,(CompilerVar, showCompilerId compilerId)]
......
......@@ -87,8 +87,10 @@ import qualified Data.Map as Map
import Distribution.Simple.Utils (die, debug, warn, rawSystemExit,
rawSystemStdout, rawSystemStdout',
withTempFile)
import Distribution.Version (Version(..), readVersion, showVersion,
VersionRange(..), withinRange, showVersionRange)
import Distribution.Version
( Version(..), VersionRange(AnyVersion), withinRange )
import Distribution.Text
( simpleParse, display )
import Distribution.Verbosity
import System.Directory (doesFileExist, removeFile, findExecutable)
import System.FilePath (dropExtension)
......@@ -181,11 +183,11 @@ findProgramVersion :: ProgArg -- ^ version args
findProgramVersion versionArg selectVersion verbosity path = do
str <- rawSystemStdout verbosity path [versionArg]
`Exception.catch` \_ -> return ""
let version = readVersion (selectVersion str)
let version = simpleParse (selectVersion str)
case version of
Nothing -> warn verbosity $ "cannot determine version of " ++ path
++ " :\n" ++ show str
Just v -> debug verbosity $ path ++ " is version " ++ showVersion v
Just v -> debug verbosity $ path ++ " is version " ++ display v
return version
-- ------------------------------------------------------------
......@@ -390,13 +392,13 @@ requireProgram verbosity prog range conf = do
++ " is required but it could not be found."
badVersion v l = programName prog ++ versionRequirement
++ " is required but the version found at "
++ locationPath l ++ " is version " ++ showVersion v
++ locationPath l ++ " is version " ++ display v
noVersion l = programName prog ++ versionRequirement
++ " is required but the version of "
++ locationPath l ++ " could not be determined."
versionRequirement
| range == AnyVersion = ""
| otherwise = " version " ++ showVersionRange range
| otherwise = " version " ++ display range
-- ------------------------------------------------------------
-- * Running programs
......
......@@ -65,7 +65,7 @@ import Distribution.PackageDescription
import Distribution.PackageDescription.Check
import Distribution.Package (showPackageId, PackageIdentifier(pkgVersion), Package(..))
import Distribution.Version
( Version(versionBranch), showVersion, VersionRange(AnyVersion) )
( Version(versionBranch), VersionRange(AnyVersion) )
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, readUTF8File, writeUTF8File
, copyFiles, copyFileVerbose, findFile, findFileWithExtension
......@@ -76,6 +76,8 @@ import Distribution.Simple.PreProcess (PPSuffixHandler, ppSuffixes, preprocessSo
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) )
import Distribution.Simple.Program ( defaultProgramConfiguration, requireProgram,
rawSystemProgram, tarProgram )
import Distribution.Text
( display )
import Control.Monad(when, unless)
import Data.Char (toLower)
......@@ -226,7 +228,7 @@ prepareSnapshotTree verbosity pkg mb_lbi tmpDir pps date = do
replaceVersion :: Version -> String -> String
replaceVersion version line
| "version:" `isPrefixOf` map toLower line
= "version: " ++ showVersion version
= "version: " ++ display version
| otherwise = line
-- | Modifies a 'Version' by appending a snapshot number corresponding
......
......@@ -6,8 +6,10 @@ module Distribution.Text (
import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import qualified Data.Char as Char (isSpace)
import Data.Version (Version(Version))
import qualified Data.Char as Char (isDigit, isAlphaNum, isSpace)
class Text a where
disp :: a -> Disp.Doc
......@@ -31,3 +33,20 @@ instance Text Bool where
Parse.string "True") >> return True
, (Parse.string "false" Parse.<++
Parse.string "False") >> return False ]
instance Text Version where
disp (Version branch tags)
= Disp.hcat (Disp.punctuate (Disp.char '.') (map Disp.int branch))
<> Disp.hcat (map (\tag -> Disp.char '-' <> Disp.text tag) tags)
parse = do
branch <- Parse.sepBy1 digits (Parse.char '.')
tags <- Parse.many (Parse.char '-' >> Parse.munch1 Char.isAlphaNum)
return (Version branch tags)
where
digits = do
first <- Parse.satisfy Char.isDigit
if first == '0'
then return 0
else do rest <- Parse.munch Char.isDigit
return (read (first : rest))
......@@ -43,47 +43,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Version (
-- * Package versions
Version(..),
showVersion,
readVersion,
parseVersion,
-- * Version ranges
VersionRange(..),
orLaterVersion, orEarlierVersion,
betweenVersionsInclusive,
withinRange,
showVersionRange,
parseVersionRange,
isAnyVersion,
) where
import Data.Version ( Version(..), showVersion )
import Data.Version ( Version(..) )
import Control.Monad ( liftM )
import Data.Char ( isSpace, isDigit, isAlphaNum )
import Data.Maybe ( listToMaybe )
import Distribution.Compat.ReadP
-- -----------------------------------------------------------------------------
-- Version utils
parseVersion :: ReadP r Version
parseVersion = do branch <- sepBy1 digits (char '.')
tags <- many (char '-' >> munch1 isAlphaNum)
return Version{versionBranch=branch, versionTags=tags}
where
digits :: ReadP r Int
digits = do first <- satisfy isDigit
if first == '0'
then return 0
else do rest <- munch isDigit
return (read (first : rest))
readVersion :: String -> Maybe Version
readVersion str =
listToMaybe [ r | (r,s) <- readP_to_S parseVersion str, all isSpace s ]
import Distribution.Text ( Text(..) )
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((+++))
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
-- -----------------------------------------------------------------------------
-- Version ranges
......@@ -133,50 +109,44 @@ withinRange v1 (UnionVersionRanges v2 v3)
withinRange v1 (IntersectVersionRanges v2 v3)
= v1 `withinRange` v2 && v1 `withinRange` v3
showVersionRange :: VersionRange -> String
showVersionRange AnyVersion = "-any"
showVersionRange (ThisVersion v) = '=' : '=' : showVersion v
showVersionRange (LaterVersion v) = '>' : showVersion v
showVersionRange (EarlierVersion v) = '<' : showVersion v
showVersionRange (UnionVersionRanges (ThisVersion v1) (LaterVersion v2