make LTS branch pre-releases
[cabal.git] / cabal-install-solver / src / Distribution / Solver / Modular / Version.hs
blob695a90aea99fb8d2d6f583e0d4dc5c6c87f05d24
1 module Distribution.Solver.Modular.Version
2 ( Ver
3 , VR
4 , anyVR
5 , checkVR
6 , eqVR
7 , showVer
8 , showVR
9 , simplifyVR
10 , (.&&.)
11 , (.||.)
12 ) where
14 import Distribution.Solver.Compat.Prelude
15 import Prelude ()
17 import qualified Distribution.Version as CV -- from Cabal
18 import Distribution.Pretty (prettyShow)
20 -- | Preliminary type for versions.
21 type Ver = CV.Version
23 -- | String representation of a version.
24 showVer :: Ver -> String
25 showVer = prettyShow
27 -- | Version range. Consists of a lower and upper bound.
28 type VR = CV.VersionRange
30 -- | String representation of a version range.
31 showVR :: VR -> String
32 showVR = prettyShow
34 -- | Unconstrained version range.
35 anyVR :: VR
36 anyVR = CV.anyVersion
38 -- | Version range fixing a single version.
39 eqVR :: Ver -> VR
40 eqVR = CV.thisVersion
42 -- | Intersect two version ranges.
43 (.&&.) :: VR -> VR -> VR
44 v1 .&&. v2 = simplifyVR $ CV.intersectVersionRanges v1 v2
46 -- | Union of two version ranges.
47 (.||.) :: VR -> VR -> VR
48 v1 .||. v2 = simplifyVR $ CV.unionVersionRanges v1 v2
50 -- | Simplify a version range.
51 simplifyVR :: VR -> VR
52 simplifyVR = CV.simplifyVersionRange
54 -- | Checking a version against a version range.
55 checkVR :: VR -> Ver -> Bool
56 checkVR = flip CV.withinRange