{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}

module Distribution.CabalSpecVersion where

import Distribution.Compat.Prelude
import Prelude ()

-- | Different Cabal-the-spec versions.
--
-- We branch based on this at least in the parser.
data CabalSpecVersion
  = -- | this is older than 'CabalSpecV1_2'
    CabalSpecV1_0
  | -- | new syntax (sections)
    CabalSpecV1_2
  | 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
  | CabalSpecV3_6
  | CabalSpecV3_8
  | -- 3.10: no changes
    CabalSpecV3_12
  deriving (CabalSpecVersion -> CabalSpecVersion -> Bool
(CabalSpecVersion -> CabalSpecVersion -> Bool)
-> (CabalSpecVersion -> CabalSpecVersion -> Bool)
-> Eq CabalSpecVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CabalSpecVersion -> CabalSpecVersion -> Bool
== :: CabalSpecVersion -> CabalSpecVersion -> Bool
$c/= :: CabalSpecVersion -> CabalSpecVersion -> Bool
/= :: 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
$ccompare :: CabalSpecVersion -> CabalSpecVersion -> Ordering
compare :: CabalSpecVersion -> CabalSpecVersion -> Ordering
$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
>= :: CabalSpecVersion -> CabalSpecVersion -> Bool
$cmax :: CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
max :: CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
$cmin :: CabalSpecVersion -> CabalSpecVersion -> CabalSpecVersion
min :: CabalSpecVersion -> CabalSpecVersion -> 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
$cshowsPrec :: Int -> CabalSpecVersion -> ShowS
showsPrec :: Int -> CabalSpecVersion -> ShowS
$cshow :: CabalSpecVersion -> String
show :: CabalSpecVersion -> String
$cshowList :: [CabalSpecVersion] -> ShowS
showList :: [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
$creadsPrec :: Int -> ReadS CabalSpecVersion
readsPrec :: Int -> ReadS CabalSpecVersion
$creadList :: ReadS [CabalSpecVersion]
readList :: ReadS [CabalSpecVersion]
$creadPrec :: ReadPrec CabalSpecVersion
readPrec :: ReadPrec CabalSpecVersion
$creadListPrec :: ReadPrec [CabalSpecVersion]
readListPrec :: ReadPrec [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
$csucc :: CabalSpecVersion -> CabalSpecVersion
succ :: CabalSpecVersion -> CabalSpecVersion
$cpred :: CabalSpecVersion -> CabalSpecVersion
pred :: CabalSpecVersion -> CabalSpecVersion
$ctoEnum :: Int -> CabalSpecVersion
toEnum :: Int -> CabalSpecVersion
$cfromEnum :: CabalSpecVersion -> Int
fromEnum :: CabalSpecVersion -> Int
$cenumFrom :: CabalSpecVersion -> [CabalSpecVersion]
enumFrom :: CabalSpecVersion -> [CabalSpecVersion]
$cenumFromThen :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
enumFromThen :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
$cenumFromTo :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
enumFromTo :: CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
$cenumFromThenTo :: CabalSpecVersion
-> CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
enumFromThenTo :: CabalSpecVersion
-> CabalSpecVersion -> CabalSpecVersion -> [CabalSpecVersion]
Enum, CabalSpecVersion
CabalSpecVersion -> CabalSpecVersion -> Bounded CabalSpecVersion
forall a. a -> a -> Bounded a
$cminBound :: CabalSpecVersion
minBound :: CabalSpecVersion
$cmaxBound :: CabalSpecVersion
maxBound :: CabalSpecVersion
Bounded, Typeable, Typeable CabalSpecVersion
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 -> Constr
CabalSpecVersion -> DataType
(forall b. Data b => b -> b)
-> CabalSpecVersion -> 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)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CabalSpecVersion -> c CabalSpecVersion
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CabalSpecVersion -> c CabalSpecVersion
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CabalSpecVersion
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CabalSpecVersion
$ctoConstr :: CabalSpecVersion -> Constr
toConstr :: CabalSpecVersion -> Constr
$cdataTypeOf :: CabalSpecVersion -> DataType
dataTypeOf :: CabalSpecVersion -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CabalSpecVersion)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CabalSpecVersion)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CabalSpecVersion)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CabalSpecVersion)
$cgmapT :: (forall b. Data b => b -> b)
-> CabalSpecVersion -> CabalSpecVersion
gmapT :: (forall b. Data b => b -> b)
-> CabalSpecVersion -> CabalSpecVersion
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
gmapQl :: forall r r'.
(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
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CabalSpecVersion -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CabalSpecVersion -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> CabalSpecVersion -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CabalSpecVersion -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CabalSpecVersion -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CabalSpecVersion -> m CabalSpecVersion
gmapM :: forall (m :: * -> *).
Monad m =>
(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
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(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
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CabalSpecVersion -> m 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
$cfrom :: forall x. CabalSpecVersion -> Rep CabalSpecVersion x
from :: forall x. CabalSpecVersion -> Rep CabalSpecVersion x
$cto :: forall x. Rep CabalSpecVersion x -> CabalSpecVersion
to :: forall x. Rep CabalSpecVersion x -> CabalSpecVersion
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_12 = String
"3.12"
showCabalSpecVersion CabalSpecVersion
CabalSpecV3_8 = String
"3.8"
showCabalSpecVersion CabalSpecVersion
CabalSpecV3_6 = String
"3.6"
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_12

-- | 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
12] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV3_12
  | [Int]
v [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int
3, Int
8] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV3_8
  | [Int]
v [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int
3, Int
6] = CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just CabalSpecVersion
CabalSpecV3_6
  | [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_12 = [Int
3, Int
12]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV3_8 = [Int
3, Int
8]
cabalSpecToVersionDigits CabalSpecVersion
CabalSpecV3_6 = [Int
3, Int
6]
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
y Int -> 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
$c== :: HasElif -> HasElif -> Bool
== :: HasElif -> HasElif -> Bool
$c/= :: HasElif -> HasElif -> Bool
/= :: 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
$cshowsPrec :: Int -> HasElif -> ShowS
showsPrec :: Int -> HasElif -> ShowS
$cshow :: HasElif -> String
show :: HasElif -> String
$cshowList :: [HasElif] -> ShowS
showList :: [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
$c== :: HasCommonStanzas -> HasCommonStanzas -> Bool
== :: HasCommonStanzas -> HasCommonStanzas -> Bool
$c/= :: HasCommonStanzas -> HasCommonStanzas -> Bool
/= :: 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
$cshowsPrec :: Int -> HasCommonStanzas -> ShowS
showsPrec :: Int -> HasCommonStanzas -> ShowS
$cshow :: HasCommonStanzas -> String
show :: HasCommonStanzas -> String
$cshowList :: [HasCommonStanzas] -> ShowS
showList :: [HasCommonStanzas] -> ShowS
Show)

data HasGlobstar = HasGlobstar | NoGlobstar