    module Distribution.Solver.Modular.Version
        ( Ver
        , VR
        , anyVR
        , checkVR
        , eqVR
        , showVer
        , showVR
        , simplifyVR
        , (.&&.)
        , (.||.)
        ) where

    import Distribution.Solver.Compat.Prelude
    import Prelude ()

    import qualified Distribution.Version as CV -- from Cabal
    import Distribution.Pretty (prettyShow)

    -- | Preliminary type for versions.
    type Ver = CV.Version

    -- | String representation of a version.
    showVer :: Ver -> String
    showVer :: Ver -> String
    showVer = Ver -> String
    forall a. Pretty a => a -> String
    prettyShow

    -- | Version range. Consists of a lower and upper bound.
    type VR = CV.VersionRange

    -- | String representation of a version range.
    showVR :: VR -> String
    showVR :: VR -> String
    showVR = VR -> String
    forall a. Pretty a => a -> String
    prettyShow

    -- | Unconstrained version range.
    anyVR :: VR
    anyVR :: VR
    anyVR = VR
    CV.anyVersion

    -- | Version range fixing a single version.
    eqVR :: Ver -> VR
    eqVR :: Ver -> VR
    eqVR = Ver -> VR
    CV.thisVersion

    -- | Intersect two version ranges.
    (.&&.) :: VR -> VR -> VR
    VR
    v1 .&&. :: VR -> VR -> VR
    .&&. VR
    v2 = VR -> VR
    simplifyVR (VR -> VR) -> VR -> VR
    forall a b. (a -> b) -> a -> b
    $ VR -> VR -> VR
    CV.intersectVersionRanges VR
    v1 VR
    v2

    -- | Union of two version ranges.
    (.||.) :: VR -> VR -> VR
    VR
    v1 .||. :: VR -> VR -> VR
    .||. VR
    v2 = VR -> VR
    simplifyVR (VR -> VR) -> VR -> VR
    forall a b. (a -> b) -> a -> b
    $ VR -> VR -> VR
    CV.unionVersionRanges VR
    v1 VR
    v2

    -- | Simplify a version range.
    simplifyVR :: VR -> VR
    simplifyVR :: VR -> VR
    simplifyVR = VR -> VR
    CV.simplifyVersionRange

    -- | Checking a version against a version range.
    checkVR :: VR -> Ver -> Bool
    checkVR :: VR -> Ver -> Bool
    checkVR = (Ver -> VR -> Bool) -> VR -> Ver -> Bool
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Ver -> VR -> Bool
    CV.withinRange