{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Distribution.Types.VersionRange.Internal
( VersionRange(..)
, anyVersion, noVersion
, thisVersion, notThisVersion
, laterVersion, earlierVersion
, orLaterVersion, orEarlierVersion
, unionVersionRanges, intersectVersionRanges
, withinVersion
, majorBoundVersion
, VersionRangeF(..)
, projectVersionRange
, embedVersionRange
, cataVersionRange
, anaVersionRange
, hyloVersionRange
, versionRangeParser
, majorUpperBound
, wildcardUpperBound
) where
import Distribution.Compat.Prelude
import Distribution.Types.Version
import Prelude ()
import Distribution.CabalSpecVersion
import Distribution.Parsec
import Distribution.Pretty
import Distribution.Utils.Generic (unsnoc)
import qualified Distribution.Compat.CharParsing as P
import qualified Distribution.Compat.DList as DList
import qualified Text.PrettyPrint as Disp
data VersionRange
= ThisVersion Version
| LaterVersion Version
| OrLaterVersion Version
| EarlierVersion Version
| OrEarlierVersion Version
| MajorBoundVersion Version
| UnionVersionRanges VersionRange VersionRange
| IntersectVersionRanges VersionRange VersionRange
deriving ( Typeable VersionRange
VersionRange -> DataType
VersionRange -> Constr
(forall b. Data b => b -> b) -> VersionRange -> VersionRange
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> VersionRange -> u
forall u. (forall d. Data d => d -> u) -> VersionRange -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRange -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRange -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c VersionRange
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VersionRange -> c VersionRange
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c VersionRange)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c VersionRange)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> VersionRange -> m VersionRange
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> VersionRange -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> VersionRange -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> VersionRange -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> VersionRange -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRange -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRange -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRange -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRange -> r
gmapT :: (forall b. Data b => b -> b) -> VersionRange -> VersionRange
$cgmapT :: (forall b. Data b => b -> b) -> VersionRange -> VersionRange
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c VersionRange)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c VersionRange)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c VersionRange)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c VersionRange)
dataTypeOf :: VersionRange -> DataType
$cdataTypeOf :: VersionRange -> DataType
toConstr :: VersionRange -> Constr
$ctoConstr :: VersionRange -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c VersionRange
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c VersionRange
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VersionRange -> c VersionRange
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VersionRange -> c VersionRange
Data, VersionRange -> VersionRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VersionRange -> VersionRange -> Bool
$c/= :: VersionRange -> VersionRange -> Bool
== :: VersionRange -> VersionRange -> Bool
$c== :: VersionRange -> VersionRange -> Bool
Eq, Eq VersionRange
VersionRange -> VersionRange -> Bool
VersionRange -> VersionRange -> Ordering
VersionRange -> VersionRange -> VersionRange
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: VersionRange -> VersionRange -> VersionRange
$cmin :: VersionRange -> VersionRange -> VersionRange
max :: VersionRange -> VersionRange -> VersionRange
$cmax :: VersionRange -> VersionRange -> VersionRange
>= :: VersionRange -> VersionRange -> Bool
$c>= :: VersionRange -> VersionRange -> Bool
> :: VersionRange -> VersionRange -> Bool
$c> :: VersionRange -> VersionRange -> Bool
<= :: VersionRange -> VersionRange -> Bool
$c<= :: VersionRange -> VersionRange -> Bool
< :: VersionRange -> VersionRange -> Bool
$c< :: VersionRange -> VersionRange -> Bool
compare :: VersionRange -> VersionRange -> Ordering
$ccompare :: VersionRange -> VersionRange -> Ordering
Ord, forall x. Rep VersionRange x -> VersionRange
forall x. VersionRange -> Rep VersionRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VersionRange x -> VersionRange
$cfrom :: forall x. VersionRange -> Rep VersionRange x
Generic, ReadPrec [VersionRange]
ReadPrec VersionRange
Int -> ReadS VersionRange
ReadS [VersionRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VersionRange]
$creadListPrec :: ReadPrec [VersionRange]
readPrec :: ReadPrec VersionRange
$creadPrec :: ReadPrec VersionRange
readList :: ReadS [VersionRange]
$creadList :: ReadS [VersionRange]
readsPrec :: Int -> ReadS VersionRange
$creadsPrec :: Int -> ReadS VersionRange
Read, Int -> VersionRange -> ShowS
[VersionRange] -> ShowS
VersionRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VersionRange] -> ShowS
$cshowList :: [VersionRange] -> ShowS
show :: VersionRange -> String
$cshow :: VersionRange -> String
showsPrec :: Int -> VersionRange -> ShowS
$cshowsPrec :: Int -> VersionRange -> ShowS
Show, Typeable )
instance Binary VersionRange
instance Structured VersionRange
instance NFData VersionRange where rnf :: VersionRange -> ()
rnf = forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
anyVersion :: VersionRange
anyVersion :: VersionRange
anyVersion = Version -> VersionRange
OrLaterVersion ([Int] -> Version
mkVersion [Int
0])
noVersion :: VersionRange
noVersion :: VersionRange
noVersion = Version -> VersionRange
EarlierVersion ([Int] -> Version
mkVersion [Int
0])
thisVersion :: Version -> VersionRange
thisVersion :: Version -> VersionRange
thisVersion = Version -> VersionRange
ThisVersion
notThisVersion :: Version -> VersionRange
notThisVersion :: Version -> VersionRange
notThisVersion Version
v = VersionRange -> VersionRange -> VersionRange
UnionVersionRanges (Version -> VersionRange
EarlierVersion Version
v) (Version -> VersionRange
LaterVersion Version
v)
laterVersion :: Version -> VersionRange
laterVersion :: Version -> VersionRange
laterVersion = Version -> VersionRange
LaterVersion
orLaterVersion :: Version -> VersionRange
orLaterVersion :: Version -> VersionRange
orLaterVersion = Version -> VersionRange
OrLaterVersion
earlierVersion :: Version -> VersionRange
earlierVersion :: Version -> VersionRange
earlierVersion = Version -> VersionRange
EarlierVersion
orEarlierVersion :: Version -> VersionRange
orEarlierVersion :: Version -> VersionRange
orEarlierVersion = Version -> VersionRange
OrEarlierVersion
unionVersionRanges :: VersionRange -> VersionRange -> VersionRange
unionVersionRanges :: VersionRange -> VersionRange -> VersionRange
unionVersionRanges = VersionRange -> VersionRange -> VersionRange
UnionVersionRanges
intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange
intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange
intersectVersionRanges = VersionRange -> VersionRange -> VersionRange
IntersectVersionRanges
withinVersion :: Version -> VersionRange
withinVersion :: Version -> VersionRange
withinVersion Version
v = VersionRange -> VersionRange -> VersionRange
intersectVersionRanges
(Version -> VersionRange
orLaterVersion Version
v)
(Version -> VersionRange
earlierVersion (Version -> Version
wildcardUpperBound Version
v))
majorBoundVersion :: Version -> VersionRange
majorBoundVersion :: Version -> VersionRange
majorBoundVersion = Version -> VersionRange
MajorBoundVersion
data VersionRangeF a
= ThisVersionF Version
| LaterVersionF Version
| OrLaterVersionF Version
| EarlierVersionF Version
| OrEarlierVersionF Version
| MajorBoundVersionF Version
| UnionVersionRangesF a a
| IntersectVersionRangesF a a
deriving ( VersionRangeF a -> DataType
VersionRangeF a -> Constr
forall {a}. Data a => Typeable (VersionRangeF a)
forall a. Data a => VersionRangeF a -> DataType
forall a. Data a => VersionRangeF a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> VersionRangeF a -> VersionRangeF a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> VersionRangeF a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> VersionRangeF a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRangeF a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRangeF a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VersionRangeF a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VersionRangeF a -> c (VersionRangeF a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (VersionRangeF a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VersionRangeF a))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VersionRangeF a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VersionRangeF a -> c (VersionRangeF a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (VersionRangeF a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> VersionRangeF a -> m (VersionRangeF a)
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> VersionRangeF a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> VersionRangeF a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> VersionRangeF a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> VersionRangeF a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRangeF a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRangeF a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRangeF a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VersionRangeF a -> r
gmapT :: (forall b. Data b => b -> b) -> VersionRangeF a -> VersionRangeF a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> VersionRangeF a -> VersionRangeF a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VersionRangeF a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VersionRangeF a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (VersionRangeF a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (VersionRangeF a))
dataTypeOf :: VersionRangeF a -> DataType
$cdataTypeOf :: forall a. Data a => VersionRangeF a -> DataType
toConstr :: VersionRangeF a -> Constr
$ctoConstr :: forall a. Data a => VersionRangeF a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VersionRangeF a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VersionRangeF a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VersionRangeF a -> c (VersionRangeF a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VersionRangeF a -> c (VersionRangeF a)
Data, VersionRangeF a -> VersionRangeF a -> Bool
forall a. Eq a => VersionRangeF a -> VersionRangeF a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VersionRangeF a -> VersionRangeF a -> Bool
$c/= :: forall a. Eq a => VersionRangeF a -> VersionRangeF a -> Bool
== :: VersionRangeF a -> VersionRangeF a -> Bool
$c== :: forall a. Eq a => VersionRangeF a -> VersionRangeF a -> Bool
Eq, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (VersionRangeF a) x -> VersionRangeF a
forall a x. VersionRangeF a -> Rep (VersionRangeF a) x
$cto :: forall a x. Rep (VersionRangeF a) x -> VersionRangeF a
$cfrom :: forall a x. VersionRangeF a -> Rep (VersionRangeF a) x
Generic, ReadPrec [VersionRangeF a]
ReadPrec (VersionRangeF a)
ReadS [VersionRangeF a]
forall a. Read a => ReadPrec [VersionRangeF a]
forall a. Read a => ReadPrec (VersionRangeF a)
forall a. Read a => Int -> ReadS (VersionRangeF a)
forall a. Read a => ReadS [VersionRangeF a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VersionRangeF a]
$creadListPrec :: forall a. Read a => ReadPrec [VersionRangeF a]
readPrec :: ReadPrec (VersionRangeF a)
$creadPrec :: forall a. Read a => ReadPrec (VersionRangeF a)
readList :: ReadS [VersionRangeF a]
$creadList :: forall a. Read a => ReadS [VersionRangeF a]
readsPrec :: Int -> ReadS (VersionRangeF a)
$creadsPrec :: forall a. Read a => Int -> ReadS (VersionRangeF a)
Read, Int -> VersionRangeF a -> ShowS
forall a. Show a => Int -> VersionRangeF a -> ShowS
forall a. Show a => [VersionRangeF a] -> ShowS
forall a. Show a => VersionRangeF a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VersionRangeF a] -> ShowS
$cshowList :: forall a. Show a => [VersionRangeF a] -> ShowS
show :: VersionRangeF a -> String
$cshow :: forall a. Show a => VersionRangeF a -> String
showsPrec :: Int -> VersionRangeF a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> VersionRangeF a -> ShowS
Show, Typeable
, forall a b. a -> VersionRangeF b -> VersionRangeF a
forall a b. (a -> b) -> VersionRangeF a -> VersionRangeF b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> VersionRangeF b -> VersionRangeF a
$c<$ :: forall a b. a -> VersionRangeF b -> VersionRangeF a
fmap :: forall a b. (a -> b) -> VersionRangeF a -> VersionRangeF b
$cfmap :: forall a b. (a -> b) -> VersionRangeF a -> VersionRangeF b
Functor, forall a. Eq a => a -> VersionRangeF a -> Bool
forall a. Num a => VersionRangeF a -> a
forall a. Ord a => VersionRangeF a -> a
forall m. Monoid m => VersionRangeF m -> m
forall a. VersionRangeF a -> Bool
forall a. VersionRangeF a -> Int
forall a. VersionRangeF a -> [a]
forall a. (a -> a -> a) -> VersionRangeF a -> a
forall m a. Monoid m => (a -> m) -> VersionRangeF a -> m
forall b a. (b -> a -> b) -> b -> VersionRangeF a -> b
forall a b. (a -> b -> b) -> b -> VersionRangeF a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => VersionRangeF a -> a
$cproduct :: forall a. Num a => VersionRangeF a -> a
sum :: forall a. Num a => VersionRangeF a -> a
$csum :: forall a. Num a => VersionRangeF a -> a
minimum :: forall a. Ord a => VersionRangeF a -> a
$cminimum :: forall a. Ord a => VersionRangeF a -> a
maximum :: forall a. Ord a => VersionRangeF a -> a
$cmaximum :: forall a. Ord a => VersionRangeF a -> a
elem :: forall a. Eq a => a -> VersionRangeF a -> Bool
$celem :: forall a. Eq a => a -> VersionRangeF a -> Bool
length :: forall a. VersionRangeF a -> Int
$clength :: forall a. VersionRangeF a -> Int
null :: forall a. VersionRangeF a -> Bool
$cnull :: forall a. VersionRangeF a -> Bool
toList :: forall a. VersionRangeF a -> [a]
$ctoList :: forall a. VersionRangeF a -> [a]
foldl1 :: forall a. (a -> a -> a) -> VersionRangeF a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> VersionRangeF a -> a
foldr1 :: forall a. (a -> a -> a) -> VersionRangeF a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> VersionRangeF a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> VersionRangeF a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> VersionRangeF a -> b
foldl :: forall b a. (b -> a -> b) -> b -> VersionRangeF a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> VersionRangeF a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> VersionRangeF a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> VersionRangeF a -> b
foldr :: forall a b. (a -> b -> b) -> b -> VersionRangeF a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> VersionRangeF a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> VersionRangeF a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> VersionRangeF a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> VersionRangeF a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> VersionRangeF a -> m
fold :: forall m. Monoid m => VersionRangeF m -> m
$cfold :: forall m. Monoid m => VersionRangeF m -> m
Foldable, Functor VersionRangeF
Foldable VersionRangeF
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
VersionRangeF (m a) -> m (VersionRangeF a)
forall (f :: * -> *) a.
Applicative f =>
VersionRangeF (f a) -> f (VersionRangeF a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> VersionRangeF a -> m (VersionRangeF b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> VersionRangeF a -> f (VersionRangeF b)
sequence :: forall (m :: * -> *) a.
Monad m =>
VersionRangeF (m a) -> m (VersionRangeF a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
VersionRangeF (m a) -> m (VersionRangeF a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> VersionRangeF a -> m (VersionRangeF b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> VersionRangeF a -> m (VersionRangeF b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
VersionRangeF (f a) -> f (VersionRangeF a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
VersionRangeF (f a) -> f (VersionRangeF a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> VersionRangeF a -> f (VersionRangeF b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> VersionRangeF a -> f (VersionRangeF b)
Traversable )
projectVersionRange :: VersionRange -> VersionRangeF VersionRange
projectVersionRange :: VersionRange -> VersionRangeF VersionRange
projectVersionRange (ThisVersion Version
v) = forall a. Version -> VersionRangeF a
ThisVersionF Version
v
projectVersionRange (LaterVersion Version
v) = forall a. Version -> VersionRangeF a
LaterVersionF Version
v
projectVersionRange (OrLaterVersion Version
v) = forall a. Version -> VersionRangeF a
OrLaterVersionF Version
v
projectVersionRange (EarlierVersion Version
v) = forall a. Version -> VersionRangeF a
EarlierVersionF Version
v
projectVersionRange (OrEarlierVersion Version
v) = forall a. Version -> VersionRangeF a
OrEarlierVersionF Version
v
projectVersionRange (MajorBoundVersion Version
v) = forall a. Version -> VersionRangeF a
MajorBoundVersionF Version
v
projectVersionRange (UnionVersionRanges VersionRange
a VersionRange
b) = forall a. a -> a -> VersionRangeF a
UnionVersionRangesF VersionRange
a VersionRange
b
projectVersionRange (IntersectVersionRanges VersionRange
a VersionRange
b) = forall a. a -> a -> VersionRangeF a
IntersectVersionRangesF VersionRange
a VersionRange
b
cataVersionRange :: (VersionRangeF a -> a) -> VersionRange -> a
cataVersionRange :: forall a. (VersionRangeF a -> a) -> VersionRange -> a
cataVersionRange VersionRangeF a -> a
f = VersionRange -> a
c where c :: VersionRange -> a
c = VersionRangeF a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap VersionRange -> a
c forall b c a. (b -> c) -> (a -> b) -> a -> c
. VersionRange -> VersionRangeF VersionRange
projectVersionRange
embedVersionRange :: VersionRangeF VersionRange -> VersionRange
embedVersionRange :: VersionRangeF VersionRange -> VersionRange
embedVersionRange (ThisVersionF Version
v) = Version -> VersionRange
ThisVersion Version
v
embedVersionRange (LaterVersionF Version
v) = Version -> VersionRange
LaterVersion Version
v
embedVersionRange (OrLaterVersionF Version
v) = Version -> VersionRange
OrLaterVersion Version
v
embedVersionRange (EarlierVersionF Version
v) = Version -> VersionRange
EarlierVersion Version
v
embedVersionRange (OrEarlierVersionF Version
v) = Version -> VersionRange
OrEarlierVersion Version
v
embedVersionRange (MajorBoundVersionF Version
v) = Version -> VersionRange
MajorBoundVersion Version
v
embedVersionRange (UnionVersionRangesF VersionRange
a VersionRange
b) = VersionRange -> VersionRange -> VersionRange
UnionVersionRanges VersionRange
a VersionRange
b
embedVersionRange (IntersectVersionRangesF VersionRange
a VersionRange
b) = VersionRange -> VersionRange -> VersionRange
IntersectVersionRanges VersionRange
a VersionRange
b
anaVersionRange :: (a -> VersionRangeF a) -> a -> VersionRange
anaVersionRange :: forall a. (a -> VersionRangeF a) -> a -> VersionRange
anaVersionRange a -> VersionRangeF a
g = a -> VersionRange
a where a :: a -> VersionRange
a = VersionRangeF VersionRange -> VersionRange
embedVersionRange forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> VersionRange
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> VersionRangeF a
g
hyloVersionRange :: (VersionRangeF VersionRange -> VersionRange)
-> (VersionRange -> VersionRangeF VersionRange)
-> VersionRange -> VersionRange
hyloVersionRange :: (VersionRangeF VersionRange -> VersionRange)
-> (VersionRange -> VersionRangeF VersionRange)
-> VersionRange
-> VersionRange
hyloVersionRange VersionRangeF VersionRange -> VersionRange
f VersionRange -> VersionRangeF VersionRange
g = VersionRange -> VersionRange
h where h :: VersionRange -> VersionRange
h = VersionRangeF VersionRange -> VersionRange
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap VersionRange -> VersionRange
h forall b c a. (b -> c) -> (a -> b) -> a -> c
. VersionRange -> VersionRangeF VersionRange
g
instance Pretty VersionRange where
pretty :: VersionRange -> Doc
pretty = forall a. Pretty a => CabalSpecVersion -> a -> Doc
prettyVersioned CabalSpecVersion
cabalSpecLatest
prettyVersioned :: CabalSpecVersion -> VersionRange -> Doc
prettyVersioned CabalSpecVersion
csv
| CabalSpecVersion
csv forall a. Ord a => a -> a -> Bool
> CabalSpecVersion
CabalSpecV1_6 = VersionRange -> Doc
prettyVersionRange
| Bool
otherwise = VersionRange -> Doc
prettyVersionRange16
prettyVersionRange :: VersionRange -> Disp.Doc
prettyVersionRange :: VersionRange -> Doc
prettyVersionRange VersionRange
vr = forall a. (VersionRangeF a -> a) -> VersionRange -> a
cataVersionRange VersionRangeF (Int -> Doc) -> Int -> Doc
alg VersionRange
vr Int
0
where
alg :: VersionRangeF (Int -> Disp.Doc) -> Int -> Disp.Doc
alg :: VersionRangeF (Int -> Doc) -> Int -> Doc
alg (ThisVersionF Version
v) Int
_ = String -> Doc
Disp.text String
"==" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
v
alg (LaterVersionF Version
v) Int
_ = String -> Doc
Disp.text String
">" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
v
alg (OrLaterVersionF Version
v) Int
_ = String -> Doc
Disp.text String
">=" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
v
alg (EarlierVersionF Version
v) Int
_ = String -> Doc
Disp.text String
"<" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
v
alg (OrEarlierVersionF Version
v) Int
_ = String -> Doc
Disp.text String
"<=" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
v
alg (MajorBoundVersionF Version
v) Int
_ = String -> Doc
Disp.text String
"^>=" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
v
alg (UnionVersionRangesF Int -> Doc
r1 Int -> Doc
r2) Int
d = Bool -> Doc -> Doc
parens (Int
d forall a. Ord a => a -> a -> Bool
> Int
0)
forall a b. (a -> b) -> a -> b
$ Int -> Doc
r1 Int
1 Doc -> Doc -> Doc
<+> String -> Doc
Disp.text String
"||" Doc -> Doc -> Doc
<+> Int -> Doc
r2 Int
0
alg (IntersectVersionRangesF Int -> Doc
r1 Int -> Doc
r2) Int
d = Bool -> Doc -> Doc
parens (Int
d forall a. Ord a => a -> a -> Bool
> Int
1)
forall a b. (a -> b) -> a -> b
$ Int -> Doc
r1 Int
2 Doc -> Doc -> Doc
<+> String -> Doc
Disp.text String
"&&" Doc -> Doc -> Doc
<+> Int -> Doc
r2 Int
1
parens :: Bool -> Doc -> Doc
parens Bool
True = Doc -> Doc
Disp.parens
parens Bool
False = forall a. a -> a
id
prettyVersionRange16 :: VersionRange -> Disp.Doc
prettyVersionRange16 :: VersionRange -> Doc
prettyVersionRange16 (IntersectVersionRanges (OrLaterVersion Version
v) (EarlierVersion Version
u))
| Version
u forall a. Eq a => a -> a -> Bool
== Version -> Version
wildcardUpperBound Version
v
= String -> Doc
Disp.text String
"==" Doc -> Doc -> Doc
<<>> Version -> Doc
dispWild Version
v
where
dispWild :: Version -> Doc
dispWild Version
ver =
[Doc] -> Doc
Disp.hcat (Doc -> [Doc] -> [Doc]
Disp.punctuate (Char -> Doc
Disp.char Char
'.')
(forall a b. (a -> b) -> [a] -> [b]
map Int -> Doc
Disp.int forall a b. (a -> b) -> a -> b
$ Version -> [Int]
versionNumbers Version
ver))
Doc -> Doc -> Doc
<<>> String -> Doc
Disp.text String
".*"
prettyVersionRange16 VersionRange
vr = VersionRange -> Doc
prettyVersionRange VersionRange
vr
instance Parsec VersionRange where
parsec :: forall (m :: * -> *). CabalParsing m => m VersionRange
parsec = forall (m :: * -> *). CabalParsing m => m CabalSpecVersion
askCabalSpecVersion forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *).
CabalParsing m =>
m Int -> CabalSpecVersion -> m VersionRange
versionRangeParser forall (m :: * -> *). CabalParsing m => m Int
versionDigitParser
versionRangeParser :: forall m. CabalParsing m => m Int -> CabalSpecVersion -> m VersionRange
versionRangeParser :: forall (m :: * -> *).
CabalParsing m =>
m Int -> CabalSpecVersion -> m VersionRange
versionRangeParser m Int
digitParser CabalSpecVersion
csv = m VersionRange
expr
where
expr :: m VersionRange
expr = do forall (m :: * -> *). CharParsing m => m ()
P.spaces
VersionRange
t <- m VersionRange
term
forall (m :: * -> *). CharParsing m => m ()
P.spaces
(do String
_ <- forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"||"
m ()
checkOp
forall (m :: * -> *). CharParsing m => m ()
P.spaces
VersionRange
e <- m VersionRange
expr
forall (m :: * -> *) a. Monad m => a -> m a
return (VersionRange -> VersionRange -> VersionRange
unionVersionRanges VersionRange
t VersionRange
e)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
forall (m :: * -> *) a. Monad m => a -> m a
return VersionRange
t)
term :: m VersionRange
term = do VersionRange
f <- m VersionRange
factor
forall (m :: * -> *). CharParsing m => m ()
P.spaces
(do String
_ <- forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"&&"
m ()
checkOp
forall (m :: * -> *). CharParsing m => m ()
P.spaces
VersionRange
t <- m VersionRange
term
forall (m :: * -> *) a. Monad m => a -> m a
return (VersionRange -> VersionRange -> VersionRange
intersectVersionRanges VersionRange
f VersionRange
t)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
forall (m :: * -> *) a. Monad m => a -> m a
return VersionRange
f)
factor :: m VersionRange
factor = forall {m :: * -> *} {a}. (Monad m, CharParsing m) => m a -> m a
parens m VersionRange
expr forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> m VersionRange
prim
prim :: m VersionRange
prim = do
String
op <- forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m String
P.munch1 Char -> Bool
isOpChar forall (m :: * -> *) a. Parsing m => m a -> String -> m a
P.<?> String
"operator"
case String
op of
String
"-" -> VersionRange
anyVersion forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"any" forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"none" forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> m VersionRange
noVersion'
String
"==" -> do
forall (m :: * -> *). CharParsing m => m ()
P.spaces
(do (Bool
wild, Version
v) <- CabalParsing m => m (Bool, Version)
verOrWild
forall {f :: * -> *}. CabalParsing f => Bool -> f ()
checkWild Bool
wild
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (if Bool
wild then Version -> VersionRange
withinVersion else Version -> VersionRange
thisVersion) Version
v
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall {f :: * -> *} {a}.
MonadFail f =>
(a -> VersionRange) -> NonEmpty a -> f VersionRange
verSet' Version -> VersionRange
thisVersion forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< CabalParsing m => m (NonEmpty Version)
verSet))
String
"^>=" -> do
forall (m :: * -> *). CharParsing m => m ()
P.spaces
(do (Bool
wild, Version
v) <- CabalParsing m => m (Bool, Version)
verOrWild
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
wild forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => String -> m a
P.unexpected forall a b. (a -> b) -> a -> b
$
String
"wild-card version after ^>= operator"
forall {f :: * -> *}. MonadFail f => Version -> f VersionRange
majorBoundVersion' Version
v
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall {f :: * -> *} {a}.
MonadFail f =>
(a -> VersionRange) -> NonEmpty a -> f VersionRange
verSet' Version -> VersionRange
majorBoundVersion forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< CabalParsing m => m (NonEmpty Version)
verSet))
String
_ -> do
forall (m :: * -> *). CharParsing m => m ()
P.spaces
(Bool
wild, Version
v) <- CabalParsing m => m (Bool, Version)
verOrWild
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
wild forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => String -> m a
P.unexpected forall a b. (a -> b) -> a -> b
$
String
"wild-card version after non-== operator: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
op
case String
op of
String
">=" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Version -> VersionRange
orLaterVersion Version
v
String
"<" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Version -> VersionRange
earlierVersion Version
v
String
"<=" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Version -> VersionRange
orEarlierVersion Version
v
String
">" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Version -> VersionRange
laterVersion Version
v
String
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Unknown version operator " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
op
checkOp :: m ()
checkOp = forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (CabalSpecVersion
csv forall a. Ord a => a -> a -> Bool
< CabalSpecVersion
CabalSpecV1_8) forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *). CabalParsing m => PWarnType -> String -> m ()
parsecWarning PWarnType
PWTVersionOperator forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords
[ String
"version operators used."
, String
"To use version operators the package needs to specify at least 'cabal-version: >= 1.8'."
]
checkWild :: Bool -> f ()
checkWild Bool
False = forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
checkWild Bool
True = forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (CabalSpecVersion
csv forall a. Ord a => a -> a -> Bool
< CabalSpecVersion
CabalSpecV1_6) forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *). CabalParsing m => PWarnType -> String -> m ()
parsecWarning PWarnType
PWTVersionWildcard forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords
[ String
"Wildcard syntax used."
, String
"To use version wildcards the package needs to specify at least 'cabal-version: >= 1.6'."
]
isOpChar :: Char -> Bool
isOpChar Char
'<' = Bool
True
isOpChar Char
'=' = Bool
True
isOpChar Char
'>' = Bool
True
isOpChar Char
'^' = Bool
True
isOpChar Char
'-' = CabalSpecVersion
csv forall a. Ord a => a -> a -> Bool
< CabalSpecVersion
CabalSpecV3_4
isOpChar Char
_ = Bool
False
noVersion' :: m VersionRange
noVersion' =
if CabalSpecVersion
csv forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV1_22
then forall (f :: * -> *) a. Applicative f => a -> f a
pure VersionRange
noVersion
else forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords
[ String
"-none version range used."
, String
"To use this syntax the package needs to specify at least 'cabal-version: 1.22'."
, String
"Alternatively, if broader compatibility is important then use"
, String
"<0 or other empty range."
]
majorBoundVersion' :: Version -> f VersionRange
majorBoundVersion' Version
v =
if CabalSpecVersion
csv forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV2_0
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Version -> VersionRange
majorBoundVersion Version
v
else forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords
[ String
"major bounded version syntax (caret, ^>=) used."
, String
"To use this syntax the package need to specify at least 'cabal-version: 2.0'."
, String
"Alternatively, if broader compatibility is important then use:"
, forall a. Pretty a => a -> String
prettyShow forall a b. (a -> b) -> a -> b
$ VersionRange -> VersionRange
eliminateMajorBoundSyntax forall a b. (a -> b) -> a -> b
$ Version -> VersionRange
majorBoundVersion Version
v
]
where
eliminateMajorBoundSyntax :: VersionRange -> VersionRange
eliminateMajorBoundSyntax = (VersionRangeF VersionRange -> VersionRange)
-> (VersionRange -> VersionRangeF VersionRange)
-> VersionRange
-> VersionRange
hyloVersionRange VersionRangeF VersionRange -> VersionRange
embed VersionRange -> VersionRangeF VersionRange
projectVersionRange
embed :: VersionRangeF VersionRange -> VersionRange
embed (MajorBoundVersionF Version
u) = VersionRange -> VersionRange -> VersionRange
intersectVersionRanges
(Version -> VersionRange
orLaterVersion Version
u) (Version -> VersionRange
earlierVersion (Version -> Version
majorUpperBound Version
u))
embed VersionRangeF VersionRange
vr = VersionRangeF VersionRange -> VersionRange
embedVersionRange VersionRangeF VersionRange
vr
verSet' :: (a -> VersionRange) -> NonEmpty a -> f VersionRange
verSet' a -> VersionRange
op NonEmpty a
vs =
if CabalSpecVersion
csv forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV3_0
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. (a -> a -> a) -> NonEmpty a -> a
foldr1 VersionRange -> VersionRange -> VersionRange
unionVersionRanges (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> VersionRange
op NonEmpty a
vs)
else forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords
[ String
"version set syntax used."
, String
"To use this syntax the package needs to specify at least 'cabal-version: 3.0'."
, String
"Alternatively, if broader compatibility is important then use"
, String
"a series of single version constraints joined with the || operator:"
, forall a. Pretty a => a -> String
prettyShow (forall a. (a -> a -> a) -> NonEmpty a -> a
foldr1 VersionRange -> VersionRange -> VersionRange
unionVersionRanges (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> VersionRange
op NonEmpty a
vs))
]
verSet :: CabalParsing m => m (NonEmpty Version)
verSet :: CabalParsing m => m (NonEmpty Version)
verSet = do
Char
_ <- forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'{'
forall (m :: * -> *). CharParsing m => m ()
P.spaces
NonEmpty Version
vs <- forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
P.sepByNonEmpty (CabalParsing m => m Version
verPlain forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (m :: * -> *). CharParsing m => m ()
P.spaces) (forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
',' forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *). CharParsing m => m ()
P.spaces)
Char
_ <- forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'}'
forall (f :: * -> *) a. Applicative f => a -> f a
pure NonEmpty Version
vs
verPlain :: CabalParsing m => m Version
verPlain :: CabalParsing m => m Version
verPlain = [Int] -> Version
mkVersion forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
P.sepByNonEmpty m Int
digitParser (forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'.')
verOrWild :: CabalParsing m => m (Bool, Version)
verOrWild :: CabalParsing m => m (Bool, Version)
verOrWild = do
Int
x <- m Int
digitParser
CabalParsing m => DList Int -> m (Bool, Version)
verLoop (forall a. a -> DList a
DList.singleton Int
x)
verLoop :: CabalParsing m => DList.DList Int -> m (Bool, Version)
verLoop :: CabalParsing m => DList Int -> m (Bool, Version)
verLoop DList Int
acc = CabalParsing m => DList Int -> m (Bool, Version)
verLoop' DList Int
acc
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (CabalParsing m => m ()
tags forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool
False, [Int] -> Version
mkVersion (forall a. DList a -> [a]
DList.toList DList Int
acc)))
verLoop' :: CabalParsing m => DList.DList Int -> m (Bool, Version)
verLoop' :: CabalParsing m => DList Int -> m (Bool, Version)
verLoop' DList Int
acc = do
Char
_ <- forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'.'
let digit :: m (Bool, Version)
digit = m Int
digitParser forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CabalParsing m => DList Int -> m (Bool, Version)
verLoop forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. DList a -> a -> DList a
DList.snoc DList Int
acc
let wild :: m (Bool, Version)
wild = (Bool
True, [Int] -> Version
mkVersion (forall a. DList a -> [a]
DList.toList DList Int
acc)) forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'*'
m (Bool, Version)
digit forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> m (Bool, Version)
wild
parens :: m a -> m a
parens m a
p = forall (m :: * -> *) bra ket a.
Applicative m =>
m bra -> m ket -> m a -> m a
P.between
((forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'(' forall (m :: * -> *) a. Parsing m => m a -> String -> m a
P.<?> String
"opening paren") forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). CharParsing m => m ()
P.spaces)
(forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
')' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). CharParsing m => m ()
P.spaces)
forall a b. (a -> b) -> a -> b
$ do
a
a <- m a
p
forall (m :: * -> *). CharParsing m => m ()
P.spaces
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
tags :: CabalParsing m => m ()
tags :: CabalParsing m => m ()
tags = do
[String]
ts <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). CharParsing m => Char -> m Char
P.char Char
'-' forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
P.satisfy Char -> Bool
isAlphaNum)
case [String]
ts of
[] -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
(String
_ : [String]
_) -> forall (m :: * -> *). CabalParsing m => PWarnType -> String -> m ()
parsecWarning PWarnType
PWTVersionTag String
"version with tags"
majorUpperBound :: Version -> Version
majorUpperBound :: Version -> Version
majorUpperBound = ([Int] -> [Int]) -> Version -> Version
alterVersion forall a b. (a -> b) -> a -> b
$ \[Int]
numbers -> case [Int]
numbers of
[] -> [Int
0,Int
1]
[Int
m1] -> [Int
m1,Int
1]
(Int
m1:Int
m2:[Int]
_) -> [Int
m1,Int
m2forall a. Num a => a -> a -> a
+Int
1]
wildcardUpperBound :: Version -> Version
wildcardUpperBound :: Version -> Version
wildcardUpperBound = ([Int] -> [Int]) -> Version -> Version
alterVersion forall a b. (a -> b) -> a -> b
$
\[Int]
lowerBound -> case forall a. [a] -> Maybe ([a], a)
unsnoc [Int]
lowerBound of
Maybe ([Int], Int)
Nothing -> []
Just ([Int]
xs, Int
x) -> [Int]
xs forall a. [a] -> [a] -> [a]
++ [Int
x forall a. Num a => a -> a -> a
+ Int
1]