{-# 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
$cfrom :: forall x. PkgconfigDependency -> Rep PkgconfigDependency x
from :: forall x. PkgconfigDependency -> Rep PkgconfigDependency x
$cto :: forall x. Rep PkgconfigDependency x -> PkgconfigDependency
to :: forall x. Rep PkgconfigDependency x -> PkgconfigDependency
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
$creadsPrec :: Int -> ReadS PkgconfigDependency
readsPrec :: Int -> ReadS PkgconfigDependency
$creadList :: ReadS [PkgconfigDependency]
readList :: ReadS [PkgconfigDependency]
$creadPrec :: ReadPrec PkgconfigDependency
readPrec :: ReadPrec PkgconfigDependency
$creadListPrec :: ReadPrec [PkgconfigDependency]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> PkgconfigDependency -> ShowS
showsPrec :: Int -> PkgconfigDependency -> ShowS
$cshow :: PkgconfigDependency -> String
show :: PkgconfigDependency -> String
$cshowList :: [PkgconfigDependency] -> ShowS
showList :: [PkgconfigDependency] -> ShowS
Show, PkgconfigDependency -> PkgconfigDependency -> Bool
(PkgconfigDependency -> PkgconfigDependency -> Bool)
-> (PkgconfigDependency -> PkgconfigDependency -> Bool)
-> Eq PkgconfigDependency
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PkgconfigDependency -> PkgconfigDependency -> Bool
== :: PkgconfigDependency -> PkgconfigDependency -> Bool
$c/= :: PkgconfigDependency -> PkgconfigDependency -> Bool
/= :: PkgconfigDependency -> PkgconfigDependency -> Bool
Eq, Typeable, Typeable PkgconfigDependency
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 -> Constr
PkgconfigDependency -> DataType
(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)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PkgconfigDependency
-> c PkgconfigDependency
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PkgconfigDependency
-> c PkgconfigDependency
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgconfigDependency
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgconfigDependency
$ctoConstr :: PkgconfigDependency -> Constr
toConstr :: PkgconfigDependency -> Constr
$cdataTypeOf :: PkgconfigDependency -> DataType
dataTypeOf :: PkgconfigDependency -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgconfigDependency)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgconfigDependency)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PkgconfigDependency)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PkgconfigDependency)
$cgmapT :: (forall b. Data b => b -> b)
-> PkgconfigDependency -> PkgconfigDependency
gmapT :: (forall b. Data b => b -> b)
-> PkgconfigDependency -> PkgconfigDependency
$cgmapQl :: 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
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgconfigDependency -> r
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> PkgconfigDependency -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u) -> PkgconfigDependency -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PkgconfigDependency -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PkgconfigDependency -> u
$cgmapM :: forall (m :: * -> *).
Monad 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
$cgmapMp :: 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
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m PkgconfigDependency
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PkgconfigDependency -> m 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 :: forall (m :: * -> *). CabalParsing m => m PkgconfigDependency
parsec = do
        PkgconfigName
name <- m PkgconfigName
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m PkgconfigName
parsec
        m ()
forall (m :: * -> *). CharParsing m => m ()
P.spaces
        PkgconfigVersionRange
verRange <- m PkgconfigVersionRange
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
forall (m :: * -> *). CabalParsing m => m PkgconfigVersionRange
parsec m PkgconfigVersionRange
-> m PkgconfigVersionRange -> m PkgconfigVersionRange
forall a. m a -> m a -> m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> PkgconfigVersionRange -> m PkgconfigVersionRange
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PkgconfigVersionRange
anyPkgconfigVersion
        PkgconfigDependency -> m PkgconfigDependency
forall a. a -> m a
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