{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
module Distribution.Types.PkgconfigDependency
  ( PkgconfigDependency(..)
  ) where

import Distribution.Compat.Prelude
import Prelude ()

import Distribution.Types.PkgconfigName
import Distribution.Types.PkgconfigVersionRange

import Distribution.Parsec
import Distribution.Pretty

import qualified Distribution.Compat.CharParsing as P

-- | Describes a dependency on a pkg-config library
--
-- @since 2.0.0.2
data PkgconfigDependency = PkgconfigDependency
                           PkgconfigName
                           PkgconfigVersionRange
                         deriving (forall x. Rep PkgconfigDependency x -> PkgconfigDependency
forall x. PkgconfigDependency -> Rep PkgconfigDependency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PkgconfigDependency x -> PkgconfigDependency
$cfrom :: forall x. PkgconfigDependency -> Rep PkgconfigDependency x
Generic, ReadPrec [PkgconfigDependency]
ReadPrec PkgconfigDependency
Int -> ReadS PkgconfigDependency
ReadS [PkgconfigDependency]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PkgconfigDependency]
$creadListPrec :: ReadPrec [PkgconfigDependency]
readPrec :: ReadPrec PkgconfigDependency
$creadPrec :: ReadPrec PkgconfigDependency
readList :: ReadS [PkgconfigDependency]
$creadList :: ReadS [PkgconfigDependency]
readsPrec :: Int -> ReadS PkgconfigDependency
$creadsPrec :: Int -> ReadS PkgconfigDependency
Read, Int -> PkgconfigDependency -> ShowS
[PkgconfigDependency] -> ShowS
PkgconfigDependency -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PkgconfigDependency] -> ShowS
$cshowList :: [PkgconfigDependency] -> ShowS
show :: PkgconfigDependency -> String
$cshow :: PkgconfigDependency -> String
showsPrec :: Int -> PkgconfigDependency -> ShowS
$cshowsPrec :: Int -> PkgconfigDependency -> ShowS
Show, PkgconfigDependency -> PkgconfigDependency -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PkgconfigDependency -> PkgconfigDependency -> Bool
$c/= :: PkgconfigDependency -> PkgconfigDependency -> Bool
== :: PkgconfigDependency -> PkgconfigDependency -> Bool
$c== :: PkgconfigDependency -> PkgconfigDependency -> Bool
Eq, Eq PkgconfigDependency
PkgconfigDependency -> PkgconfigDependency -> Bool
PkgconfigDependency -> PkgconfigDependency -> Ordering
PkgconfigDependency -> PkgconfigDependency -> PkgconfigDependency
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 :: PkgconfigDependency -> PkgconfigDependency -> PkgconfigDependency
$cmin :: PkgconfigDependency -> PkgconfigDependency -> PkgconfigDependency
max :: PkgconfigDependency -> PkgconfigDependency -> PkgconfigDependency
$cmax :: PkgconfigDependency -> PkgconfigDependency -> PkgconfigDependency
>= :: PkgconfigDependency -> PkgconfigDependency -> Bool
$c>= :: PkgconfigDependency -> PkgconfigDependency -> Bool
> :: PkgconfigDependency -> PkgconfigDependency -> Bool
$c> :: PkgconfigDependency -> PkgconfigDependency -> Bool
<= :: PkgconfigDependency -> PkgconfigDependency -> Bool
$c<= :: PkgconfigDependency -> PkgconfigDependency -> Bool
< :: PkgconfigDependency -> PkgconfigDependency -> Bool
$c< :: PkgconfigDependency -> PkgconfigDependency -> Bool
compare :: PkgconfigDependency -> PkgconfigDependency -> Ordering
$ccompare :: PkgconfigDependency -> PkgconfigDependency -> Ordering
Ord, Typeable, Typeable PkgconfigDependency
PkgconfigDependency -> DataType
PkgconfigDependency -> Constr
(forall b. Data b => b -> b)
-> PkgconfigDependency -> PkgconfigDependency
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) -> PkgconfigDependency -> u
forall u.
(forall d. Data d => d -> u) -> PkgconfigDependency -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgconfigDependency
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PkgconfigDependency
-> c PkgconfigDependency
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgconfigDependency)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PkgconfigDependency)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PkgconfigDependency -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PkgconfigDependency -> u
gmapQ :: forall u.
(forall d. Data d => d -> u) -> PkgconfigDependency -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> PkgconfigDependency -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
gmapT :: (forall b. Data b => b -> b)
-> PkgconfigDependency -> PkgconfigDependency
$cgmapT :: (forall b. Data b => b -> b)
-> PkgconfigDependency -> PkgconfigDependency
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PkgconfigDependency)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PkgconfigDependency)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgconfigDependency)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgconfigDependency)
dataTypeOf :: PkgconfigDependency -> DataType
$cdataTypeOf :: PkgconfigDependency -> DataType
toConstr :: PkgconfigDependency -> Constr
$ctoConstr :: PkgconfigDependency -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgconfigDependency
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgconfigDependency
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PkgconfigDependency
-> c PkgconfigDependency
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PkgconfigDependency
-> c PkgconfigDependency
Data)

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

instance Pretty PkgconfigDependency where
    pretty :: PkgconfigDependency -> Doc
pretty (PkgconfigDependency PkgconfigName
name PkgconfigVersionRange
PcAnyVersion) = forall a. Pretty a => a -> Doc
pretty PkgconfigName
name
    pretty (PkgconfigDependency PkgconfigName
name PkgconfigVersionRange
ver)          = forall a. Pretty a => a -> Doc
pretty PkgconfigName
name Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pretty PkgconfigVersionRange
ver

instance Parsec PkgconfigDependency where
    parsec :: forall (m :: * -> *). CabalParsing m => m PkgconfigDependency
parsec = do
        PkgconfigName
name <- forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec
        forall (m :: * -> *). CharParsing m => m ()
P.spaces
        PkgconfigVersionRange
verRange <- forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure PkgconfigVersionRange
anyPkgconfigVersion
        forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ PkgconfigName -> PkgconfigVersionRange -> PkgconfigDependency
PkgconfigDependency PkgconfigName
name PkgconfigVersionRange
verRange