{-# 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. PkgconfigDependency -> Rep PkgconfigDependency x)
-> (forall x. Rep PkgconfigDependency x -> PkgconfigDependency)
-> Generic PkgconfigDependency
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]
(Int -> ReadS PkgconfigDependency)
-> ReadS [PkgconfigDependency]
-> ReadPrec PkgconfigDependency
-> ReadPrec [PkgconfigDependency]
-> Read 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
(Int -> PkgconfigDependency -> ShowS)
-> (PkgconfigDependency -> String)
-> ([PkgconfigDependency] -> ShowS)
-> Show PkgconfigDependency
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
(PkgconfigDependency -> PkgconfigDependency -> Bool)
-> (PkgconfigDependency -> PkgconfigDependency -> Bool)
-> Eq PkgconfigDependency
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, Typeable, Typeable PkgconfigDependency
DataType
Constr
Typeable PkgconfigDependency
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> PkgconfigDependency
    -> c PkgconfigDependency)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PkgconfigDependency)
-> (PkgconfigDependency -> Constr)
-> (PkgconfigDependency -> DataType)
-> (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))
-> ((forall b. Data b => b -> b)
    -> PkgconfigDependency -> PkgconfigDependency)
-> (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 u.
    (forall d. Data d => d -> u) -> PkgconfigDependency -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> PkgconfigDependency -> u)
-> (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 (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> PkgconfigDependency -> m PkgconfigDependency)
-> Data PkgconfigDependency
PkgconfigDependency -> DataType
PkgconfigDependency -> Constr
(forall b. Data b => b -> b)
-> PkgconfigDependency -> PkgconfigDependency
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PkgconfigDependency
-> c PkgconfigDependency
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cPkgconfigDependency :: Constr
$tPkgconfigDependency :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> PkgconfigDependency -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PkgconfigDependency -> u
gmapQ :: (forall d. Data d => d -> u) -> PkgconfigDependency -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> PkgconfigDependency -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable PkgconfigDependency
Data)

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

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

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