{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.CabalSpecVersion where

import Prelude ()
import Distribution.Compat.Prelude

-- | Different Cabal-the-spec versions.
--
-- We branch based on this at least in the parser.
--
data CabalSpecVersion
    = CabalSpecV1_0 -- ^ this is older than 'CabalSpecV1_2'
    | CabalSpecV1_2 -- ^ new syntax (sections)
    | CabalSpecV1_4
    | CabalSpecV1_6
    | CabalSpecV1_8
    | CabalSpecV1_10
    | CabalSpecV1_12
    -- 1.16 -- 1.14: no changes
    | CabalSpecV1_18
    | CabalSpecV1_20
    | CabalSpecV1_22
    | CabalSpecV1_24
    | CabalSpecV2_0
    | CabalSpecV2_2
    | CabalSpecV2_4
    | CabalSpecV3_0
    -- 3.2: no changes
    | CabalSpecV3_4
  deriving (CabalSpecVersion -> CabalSpecVersion -> Bool
(CabalSpecVersion -> CabalSpecVersion -> Bool)
-> (CabalSpecVersion -> CabalSpecVersion -> Bool)
-> Eq CabalSpecVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CabalSpecVersion -> CabalSpecVersion -> Bool
$c/= :: CabalSpecVersion -> CabalSpecVersion -> Bool
== :: CabalSpecVersion -> CabalSpecVersion -> Bool
$c== :: CabalSpecVersion -> CabalSpecVersion -> Bool
Eq, Eq CabalSpecVersion
Eq CabalSpecVersion
-> (CabalSpecVersion -> CabalSpecVersion -> Ordering)
-> (CabalSpecVersion -> CabalSpecVersion -> Bool)
-> (CabalSpecVersion -> CabalSpecVersion -> Bool)
-> (CabalSpecVersion -> CabalSpecVersion -> Bool)
-> (CabalSpecVersion -> CabalSpecVersion -> Bool)
-> (CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion)
-> (CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion)
-> Ord CabalSpecVersion
CabalSpecVersion -> CabalSpecVersion -> Bool
CabalSpecVersion -> CabalSpecVersion -> Ordering
CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
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 :: CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
$cmin :: CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
max :: CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
$cmax :: CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
>= :: CabalSpecVersion -> CabalSpecVersion -> Bool
$c>= :: CabalSpecVersion -> CabalSpecVersion -> Bool
> :: CabalSpecVersion -> CabalSpecVersion -> Bool
$c> :: CabalSpecVersion -> CabalSpecVersion -> Bool
<= :: CabalSpecVersion -> CabalSpecVersion -> Bool
$c<= :: CabalSpecVersion -> CabalSpecVersion -> Bool
< :: CabalSpecVersion -> CabalSpecVersion -> Bool
$c< :: CabalSpecVersion -> CabalSpecVersion -> Bool
compare :: CabalSpecVersion -> CabalSpecVersion -> Ordering
$ccompare :: CabalSpecVersion -> CabalSpecVersion -> Ordering
$cp1Ord :: Eq CabalSpecVersion
Ord, Int -> CabalSpecVersion -> ShowS
[CabalSpecVersion] -> ShowS
CabalSpecVersion -> String
(Int -> CabalSpecVersion -> ShowS)
-> (CabalSpecVersion -> String)
-> ([CabalSpecVersion] -> ShowS)
-> Show CabalSpecVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CabalSpecVersion] -> ShowS
$cshowList :: [CabalSpecVersion] -> ShowS
show :: CabalSpecVersion -> String
$cshow :: CabalSpecVersion -> String
showsPrec :: Int -> CabalSpecVersion -> ShowS
$cshowsPrec :: Int -> CabalSpecVersion -> ShowS
Show, ReadPrec [CabalSpecVersion]
ReadPrec CabalSpecVersion
Int -> ReadS CabalSpecVersion
ReadS [CabalSpecVersion]
(Int -> ReadS CabalSpecVersion)
-> ReadS [CabalSpecVersion]
-> ReadPrec CabalSpecVersion
-> ReadPrec [CabalSpecVersion]
-> Read CabalSpecVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CabalSpecVersion]
$creadListPrec :: ReadPrec [CabalSpecVersion]
readPrec :: ReadPrec CabalSpecVersion
$creadPrec :: ReadPrec CabalSpecVersion
readList :: ReadS [CabalSpecVersion]
$creadList :: ReadS [CabalSpecVersion]
readsPrec :: Int -> ReadS CabalSpecVersion
$creadsPrec :: Int -> ReadS CabalSpecVersion
Read, Int -> CabalSpecVersion
CabalSpecVersion -> Int
CabalSpecVersion -> [CabalSpecVersion]
CabalSpecVersion -> CabalSpecVersion
CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
CabalSpecVersion
-> CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
(CabalSpecVersion -> CabalSpecVersion)
-> (CabalSpecVersion -> CabalSpecVersion)
-> (Int -> CabalSpecVersion)
-> (CabalSpecVersion -> Int)
-> (CabalSpecVersion -> [CabalSpecVersion])
-> (CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion])
-> (CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion])
-> (CabalSpecVersion
    -> CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion])
-> Enum CabalSpecVersion
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: CabalSpecVersion
-> CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
$cenumFromThenTo :: CabalSpecVersion
-> CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
enumFromTo :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
$cenumFromTo :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
enumFromThen :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
$cenumFromThen :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
enumFrom :: CabalSpecVersion -> [CabalSpecVersion]
$cenumFrom :: CabalSpecVersion -> [CabalSpecVersion]
fromEnum :: CabalSpecVersion -> Int
$cfromEnum :: CabalSpecVersion -> Int
toEnum :: Int -> CabalSpecVersion
$ctoEnum :: Int -> CabalSpecVersion
pred :: CabalSpecVersion -> CabalSpecVersion
$cpred :: CabalSpecVersion -> CabalSpecVersion
succ :: CabalSpecVersion -> CabalSpecVersion
$csucc :: CabalSpecVersion -> CabalSpecVersion
Enum, CabalSpecVersion
CabalSpecVersion -> CabalSpecVersion -> Bounded CabalSpecVersion
forall a. a -> a -> Bounded a
maxBound :: CabalSpecVersion
$cmaxBound :: CabalSpecVersion
minBound :: CabalSpecVersion
$cminBound :: CabalSpecVersion
Bounded, Typeable, Typeable CabalSpecVersion
DataType
Constr
Typeable CabalSpecVersion
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CabalSpecVersion -> c CabalSpecVersion)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CabalSpecVersion)
-> (CabalSpecVersion -> Constr)
-> (CabalSpecVersion -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CabalSpecVersion))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CabalSpecVersion))
-> ((forall b. Data b => b -> b)
    -> CabalSpecVersion -> CabalSpecVersion)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> CabalSpecVersion -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CabalSpecVersion -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> CabalSpecVersion -> m CabalSpecVersion)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CabalSpecVersion -> m CabalSpecVersion)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CabalSpecVersion -> m CabalSpecVersion)
-> Data CabalSpecVersion
CabalSpecVersion -> DataType
CabalSpecVersion -> Constr
(forall b. Data b => b -> b)
-> CabalSpecVersion -> CabalSpecVersion
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CabalSpecVersion -> c CabalSpecVersion
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CabalSpecVersion
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) -> CabalSpecVersion -> u
forall u. (forall d. Data d => d -> u) -> CabalSpecVersion -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CabalSpecVersion
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CabalSpecVersion -> c CabalSpecVersion
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CabalSpecVersion)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CabalSpecVersion)
$cCabalSpecV3_4 :: Constr
$cCabalSpecV3_0 :: Constr
$cCabalSpecV2_4 :: Constr
$cCabalSpecV2_2 :: Constr
$cCabalSpecV2_0 :: Constr
$cCabalSpecV1_24 :: Constr
$cCabalSpecV1_22 :: Constr
$cCabalSpecV1_20 :: Constr
$cCabalSpecV1_18 :: Constr
$cCabalSpecV1_12 :: Constr
$cCabalSpecV1_10 :: Constr
$cCabalSpecV1_8 :: Constr
$cCabalSpecV1_6 :: Constr
$cCabalSpecV1_4 :: Constr
$cCabalSpecV1_2 :: Constr
$cCabalSpecV1_0 :: Constr
$tCabalSpecVersion :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
gmapMp :: (forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
gmapM :: (forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
gmapQi :: Int -> (forall d. Data d => d -> u) -> CabalSpecVersion -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CabalSpecVersion -> u
gmapQ :: (forall d. Data d => d -> u) -> CabalSpecVersion -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CabalSpecVersion -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
gmapT :: (forall b. Data b => b -> b)
-> CabalSpecVersion -> CabalSpecVersion
$cgmapT :: (forall b. Data b => b -> b)
-> CabalSpecVersion -> CabalSpecVersion
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CabalSpecVersion)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CabalSpecVersion)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CabalSpecVersion)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CabalSpecVersion)
dataTypeOf :: CabalSpecVersion -> DataType
$cdataTypeOf :: CabalSpecVersion -> DataType
toConstr :: CabalSpecVersion -> Constr
$ctoConstr :: CabalSpecVersion -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CabalSpecVersion
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CabalSpecVersion
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CabalSpecVersion -> c CabalSpecVersion
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CabalSpecVersion -> c CabalSpecVersion
$cp1Data :: Typeable CabalSpecVersion
Data, (forall x. CabalSpecVersion -> Rep CabalSpecVersion x)
-> (forall x. Rep CabalSpecVersion x -> CabalSpecVersion)
-> Generic CabalSpecVersion
forall x. Rep CabalSpecVersion x -> CabalSpecVersion
forall x. CabalSpecVersion -> Rep CabalSpecVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CabalSpecVersion x -> CabalSpecVersion
$cfrom :: forall x. CabalSpecVersion -> Rep CabalSpecVersion x
Generic)

instance Binary CabalSpecVersion
instance Structured CabalSpecVersion
instance NFData CabalSpecVersion where rnf :: CabalSpecVersion -> ()
rnf = CabalSpecVersion -> ()
forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf

-- | Show cabal spec version, but not the way in the .cabal files
--
-- @since 3.0.0.0
showCabalSpecVersion :: CabalSpecVersion -> String
showCabalSpecVersion :: CabalSpecVersion -> String
showCabalSpecVersion CabalSpecVersion
CabalSpecV3_4  = String
"3.4"
showCabalSpecVersion CabalSpecVersion
CabalSpecV3_0  = String
"3.0"
showCabalSpecVersion CabalSpecVersion
CabalSpecV2_4  = String
"2.4"
showCabalSpecVersion CabalSpecVersion
CabalSpecV2_2  = String
"2.2"
showCabalSpecVersion CabalSpecVersion
CabalSpecV2_0  = String
"2.0"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_24 = String
"1.24"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_22 = String
"1.22"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_20 = String
"1.20"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_18 = String
"1.18"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_12 = String
"1.12"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_10 = String
"1.10"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_8  = String
"1.8"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_6  = String
"1.6"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_4  = String
"1.4"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_2  = String
"1.2"
showCabalSpecVersion CabalSpecVersion
CabalSpecV1_0  = String
"1.0"

cabalSpecLatest :: CabalSpecVersion
cabalSpecLatest :: CabalSpecVersion
cabalSpecLatest = CabalSpecVersion
CabalSpecV3_4

-- | Parse 'CabalSpecVersion' from version digits.
--
-- It may fail if for recent versions the version is not exact.
--
cabalSpecFromVersionDigits :: [Int] -> Maybe CabalSpecVersion
cabalSpecFromVersionDigits :: [Int] -> Maybe CabalSpecVersion
cabalSpecFromVersionDigits [Int]
v
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int
3,Int
4]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV3_4
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int
3,Int
0]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV3_0
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int
2,Int
4]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV2_4
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int
2,Int
2]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV2_2
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int
2,Int
0]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV2_0
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
25] = Maybe CabalSpecVersion
forall a. Maybe a
Nothing
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
23] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_24
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
21] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_22
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
19] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_20
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
17] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_18
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
11] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_12
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
9]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_10
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
7]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_8
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
5]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_6
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
3]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_4
    | [Int]
v [Int] -> [Int] -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
1,Int
1]  = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_2
    | Bool
otherwise   = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV1_0

-- | @since 3.4.0.0
cabalSpecToVersionDigits :: CabalSpecVersion -> [Int]
cabalSpecToVersionDigits :: CabalSpecVersion -> [Int]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV3_4   = [Int
3,Int
4]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV3_0   = [Int
3,Int
0]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV2_4   = [Int
2,Int
4]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV2_2   = [Int
2,Int
2]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV2_0   = [Int
2,Int
0]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_24  = [Int
1,Int
24]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_22  = [Int
1,Int
22]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_20  = [Int
1,Int
20]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_18  = [Int
1,Int
18]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_12  = [Int
1,Int
12]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_10  = [Int
1,Int
10]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_8   = [Int
1,Int
8]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_6   = [Int
1,Int
6]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_4   = [Int
1,Int
4]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_2   = [Int
1,Int
2]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV1_0   = [Int
1,Int
0]

-- | What is the minimum Cabal library version which knows how handle
-- this spec version.
--
-- /Note:/ this is a point where we could decouple cabal-spec and Cabal
-- versions, if we ever want that.
--
-- >>> cabalSpecMinimumLibraryVersion CabalSpecV3_0
-- [2,5]
--
-- >>> cabalSpecMinimumLibraryVersion CabalSpecV2_4
-- [2,3]
--
-- @since 3.4.0.0
cabalSpecMinimumLibraryVersion :: CabalSpecVersion -> [Int]
cabalSpecMinimumLibraryVersion :: CabalSpecVersion -> [Int]
cabalSpecMinimumLibraryVersion CabalSpecVersion
CabalSpecV1_0 = [Int
1,Int
0]
cabalSpecMinimumLibraryVersion CabalSpecVersion
csv = case CabalSpecVersion -> [Int]
cabalSpecToVersionDigits (CabalSpecVersion -> CabalSpecVersion
forall a. Enum a => a -> a
pred CabalSpecVersion
csv) of
    [Int
x,Int
y] -> [Int
x, Int
yInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1]
    [Int]
xs    -> [Int]
xs

specHasCommonStanzas :: CabalSpecVersion -> HasCommonStanzas
specHasCommonStanzas :: CabalSpecVersion -> HasCommonStanzas
specHasCommonStanzas CabalSpecVersion
v =
    if CabalSpecVersion
v CabalSpecVersion -> CabalSpecVersion -> Bool
forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV2_2
    then HasCommonStanzas
HasCommonStanzas
    else HasCommonStanzas
NoCommonStanzas

specHasElif :: CabalSpecVersion -> HasElif
specHasElif :: CabalSpecVersion -> HasElif
specHasElif CabalSpecVersion
v = 
    if CabalSpecVersion
v CabalSpecVersion -> CabalSpecVersion -> Bool
forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV2_2
    then HasElif
HasElif
    else HasElif
NoElif

-------------------------------------------------------------------------------
-- Booleans
-------------------------------------------------------------------------------

-- IDEA: make some kind of tagged booleans?
data HasElif = HasElif | NoElif
  deriving (HasElif -> HasElif -> Bool
(HasElif -> HasElif -> Bool)
-> (HasElif -> HasElif -> Bool) -> Eq HasElif
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HasElif -> HasElif -> Bool
$c/= :: HasElif -> HasElif -> Bool
== :: HasElif -> HasElif -> Bool
$c== :: HasElif -> HasElif -> Bool
Eq, Int -> HasElif -> ShowS
[HasElif] -> ShowS
HasElif -> String
(Int -> HasElif -> ShowS)
-> (HasElif -> String) -> ([HasElif] -> ShowS) -> Show HasElif
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HasElif] -> ShowS
$cshowList :: [HasElif] -> ShowS
show :: HasElif -> String
$cshow :: HasElif -> String
showsPrec :: Int -> HasElif -> ShowS
$cshowsPrec :: Int -> HasElif -> ShowS
Show)

data HasCommonStanzas = HasCommonStanzas | NoCommonStanzas
  deriving (HasCommonStanzas -> HasCommonStanzas -> Bool
(HasCommonStanzas -> HasCommonStanzas -> Bool)
-> (HasCommonStanzas -> HasCommonStanzas -> Bool)
-> Eq HasCommonStanzas
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HasCommonStanzas -> HasCommonStanzas -> Bool
$c/= :: HasCommonStanzas -> HasCommonStanzas -> Bool
== :: HasCommonStanzas -> HasCommonStanzas -> Bool
$c== :: HasCommonStanzas -> HasCommonStanzas -> Bool
Eq, Int -> HasCommonStanzas -> ShowS
[HasCommonStanzas] -> ShowS
HasCommonStanzas -> String
(Int -> HasCommonStanzas -> ShowS)
-> (HasCommonStanzas -> String)
-> ([HasCommonStanzas] -> ShowS)
-> Show HasCommonStanzas
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HasCommonStanzas] -> ShowS
$cshowList :: [HasCommonStanzas] -> ShowS
show :: HasCommonStanzas -> String
$cshow :: HasCommonStanzas -> String
showsPrec :: Int -> HasCommonStanzas -> ShowS
$cshowsPrec :: Int -> HasCommonStanzas -> ShowS
Show)

data HasGlobstar = HasGlobstar | NoGlobstar