    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE TypeSynonymInstances #-}
    {-# LANGUAGE PatternSynonyms #-}
    module Debian.Relation.Common (
        AndRelation
      , ArchitectureReq(..)
      , BinPkgName(..)
      , checkVersionReq
      , OrRelation
      , ParseRelations(..)
      , PkgName(..)
      , Relation(.., Rel)
      , Relations
      , SrcPkgName(..)
      , VersionReq(..)
      , RestrictionList
    )
    where

    -- Standard GHC Modules

    import Data.Data (Data)
    import Data.Function
    import Data.List as List (map, intersperse)
    import Data.Map.Ordered (OMap)
    import qualified Data.Map.Ordered as MO
    import Data.Set as Set (Set, toList)
    import Data.Typeable (Typeable)
    import Debian.Arch (Arch, prettyArch)
    import Debian.Pretty (PP(..))
    import Prelude hiding (map)
    import Text.ParserCombinators.Parsec
    import Text.PrettyPrint (Doc, text, empty)
    import Distribution.Pretty (Pretty(pretty))

    -- Local Modules

    import Debian.Version

    -- Datatype for relations

    type Relations = AndRelation
    type AndRelation = [OrRelation]
    type OrRelation = [Relation]

    type RestrictionList = OMap String Bool

    data Relation = RRel BinPkgName (Maybe VersionReq) (Maybe ArchitectureReq) [RestrictionList] deriving (Relation -> Relation -> Bool
    (Relation -> Relation -> Bool)
    -> (Relation -> Relation -> Bool) -> Eq Relation
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Relation -> Relation -> Bool
    == :: Relation -> Relation -> Bool
    $c/= :: Relation -> Relation -> Bool
    /= :: Relation -> Relation -> Bool
    Eq, ReadPrec [Relation]
    ReadPrec Relation
    Int -> ReadS Relation
    ReadS [Relation]
    (Int -> ReadS Relation)
    -> ReadS [Relation]
    -> ReadPrec Relation
    -> ReadPrec [Relation]
    -> Read Relation
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Relation
    readsPrec :: Int -> ReadS Relation
    $creadList :: ReadS [Relation]
    readList :: ReadS [Relation]
    $creadPrec :: ReadPrec Relation
    readPrec :: ReadPrec Relation
    $creadListPrec :: ReadPrec [Relation]
    readListPrec :: ReadPrec [Relation]
    Read, Int -> Relation -> ShowS
    [Relation] -> ShowS
    Relation -> [Char]
    (Int -> Relation -> ShowS)
    -> (Relation -> [Char]) -> ([Relation] -> ShowS) -> Show Relation
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Relation -> ShowS
    showsPrec :: Int -> Relation -> ShowS
    $cshow :: Relation -> [Char]
    show :: Relation -> [Char]
    $cshowList :: [Relation] -> ShowS
    showList :: [Relation] -> ShowS
    Show)

    {-# DEPRECATED Rel "Switch to RRel" #-}
    pattern Rel :: BinPkgName -> Maybe VersionReq -> Maybe ArchitectureReq -> Relation
    pattern $mRel :: forall {r}.
    Relation
    -> (BinPkgName -> Maybe VersionReq -> Maybe ArchitectureReq -> r)
    -> ((# #) -> r)
    -> r
    $bRel :: BinPkgName -> Maybe VersionReq -> Maybe ArchitectureReq -> Relation
    Rel a mb mc <- RRel a mb mc _ where
      Rel BinPkgName
    a Maybe VersionReq
    mb Maybe ArchitectureReq
    mc = BinPkgName
    -> Maybe VersionReq
    -> Maybe ArchitectureReq
    -> [RestrictionList]
    -> Relation
    RRel BinPkgName
    a Maybe VersionReq
    mb Maybe ArchitectureReq
    mc []

    newtype SrcPkgName = SrcPkgName {SrcPkgName -> [Char]
    unSrcPkgName :: String} deriving (ReadPrec [SrcPkgName]
    ReadPrec SrcPkgName
    Int -> ReadS SrcPkgName
    ReadS [SrcPkgName]
    (Int -> ReadS SrcPkgName)
    -> ReadS [SrcPkgName]
    -> ReadPrec SrcPkgName
    -> ReadPrec [SrcPkgName]
    -> Read SrcPkgName
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS SrcPkgName
    readsPrec :: Int -> ReadS SrcPkgName
    $creadList :: ReadS [SrcPkgName]
    readList :: ReadS [SrcPkgName]
    $creadPrec :: ReadPrec SrcPkgName
    readPrec :: ReadPrec SrcPkgName
    $creadListPrec :: ReadPrec [SrcPkgName]
    readListPrec :: ReadPrec [SrcPkgName]
    Read, Int -> SrcPkgName -> ShowS
    [SrcPkgName] -> ShowS
    SrcPkgName -> [Char]
    (Int -> SrcPkgName -> ShowS)
    -> (SrcPkgName -> [Char])
    -> ([SrcPkgName] -> ShowS)
    -> Show SrcPkgName
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> SrcPkgName -> ShowS
    showsPrec :: Int -> SrcPkgName -> ShowS
    $cshow :: SrcPkgName -> [Char]
    show :: SrcPkgName -> [Char]
    $cshowList :: [SrcPkgName] -> ShowS
    showList :: [SrcPkgName] -> ShowS
    Show, SrcPkgName -> SrcPkgName -> Bool
    (SrcPkgName -> SrcPkgName -> Bool)
    -> (SrcPkgName -> SrcPkgName -> Bool) -> Eq SrcPkgName
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: SrcPkgName -> SrcPkgName -> Bool
    == :: SrcPkgName -> SrcPkgName -> Bool
    $c/= :: SrcPkgName -> SrcPkgName -> Bool
    /= :: SrcPkgName -> SrcPkgName -> Bool
    Eq, Eq SrcPkgName
    Eq SrcPkgName =>
    (SrcPkgName -> SrcPkgName -> Ordering)
    -> (SrcPkgName -> SrcPkgName -> Bool)
    -> (SrcPkgName -> SrcPkgName -> Bool)
    -> (SrcPkgName -> SrcPkgName -> Bool)
    -> (SrcPkgName -> SrcPkgName -> Bool)
    -> (SrcPkgName -> SrcPkgName -> SrcPkgName)
    -> (SrcPkgName -> SrcPkgName -> SrcPkgName)
    -> Ord SrcPkgName
    SrcPkgName -> SrcPkgName -> Bool
    SrcPkgName -> SrcPkgName -> Ordering
    SrcPkgName -> SrcPkgName -> SrcPkgName
    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 :: SrcPkgName -> SrcPkgName -> Ordering
    compare :: SrcPkgName -> SrcPkgName -> Ordering
    $c< :: SrcPkgName -> SrcPkgName -> Bool
    < :: SrcPkgName -> SrcPkgName -> Bool
    $c<= :: SrcPkgName -> SrcPkgName -> Bool
    <= :: SrcPkgName -> SrcPkgName -> Bool
    $c> :: SrcPkgName -> SrcPkgName -> Bool
    > :: SrcPkgName -> SrcPkgName -> Bool
    $c>= :: SrcPkgName -> SrcPkgName -> Bool
    >= :: SrcPkgName -> SrcPkgName -> Bool
    $cmax :: SrcPkgName -> SrcPkgName -> SrcPkgName
    max :: SrcPkgName -> SrcPkgName -> SrcPkgName
    $cmin :: SrcPkgName -> SrcPkgName -> SrcPkgName
    min :: SrcPkgName -> SrcPkgName -> SrcPkgName
    Ord, Typeable SrcPkgName
    Typeable SrcPkgName =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> SrcPkgName -> c SrcPkgName)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c SrcPkgName)
    -> (SrcPkgName -> Constr)
    -> (SrcPkgName -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c SrcPkgName))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c SrcPkgName))
    -> ((forall b. Data b => b -> b) -> SrcPkgName -> SrcPkgName)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r)
    -> (forall u. (forall d. Data d => d -> u) -> SrcPkgName -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> SrcPkgName -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName)
    -> Data SrcPkgName
    SrcPkgName -> Constr
    SrcPkgName -> DataType
    (forall b. Data b => b -> b) -> SrcPkgName -> SrcPkgName
    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) -> SrcPkgName -> u
    forall u. (forall d. Data d => d -> u) -> SrcPkgName -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SrcPkgName
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SrcPkgName -> c SrcPkgName
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SrcPkgName)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcPkgName)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SrcPkgName -> c SrcPkgName
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SrcPkgName -> c SrcPkgName
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SrcPkgName
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SrcPkgName
    $ctoConstr :: SrcPkgName -> Constr
    toConstr :: SrcPkgName -> Constr
    $cdataTypeOf :: SrcPkgName -> DataType
    dataTypeOf :: SrcPkgName -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SrcPkgName)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SrcPkgName)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcPkgName)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcPkgName)
    $cgmapT :: (forall b. Data b => b -> b) -> SrcPkgName -> SrcPkgName
    gmapT :: (forall b. Data b => b -> b) -> SrcPkgName -> SrcPkgName
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SrcPkgName -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> SrcPkgName -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> SrcPkgName -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SrcPkgName -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SrcPkgName -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SrcPkgName -> m SrcPkgName
    Data, Typeable)
    newtype BinPkgName = BinPkgName {BinPkgName -> [Char]
    unBinPkgName :: String} deriving (ReadPrec [BinPkgName]
    ReadPrec BinPkgName
    Int -> ReadS BinPkgName
    ReadS [BinPkgName]
    (Int -> ReadS BinPkgName)
    -> ReadS [BinPkgName]
    -> ReadPrec BinPkgName
    -> ReadPrec [BinPkgName]
    -> Read BinPkgName
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS BinPkgName
    readsPrec :: Int -> ReadS BinPkgName
    $creadList :: ReadS [BinPkgName]
    readList :: ReadS [BinPkgName]
    $creadPrec :: ReadPrec BinPkgName
    readPrec :: ReadPrec BinPkgName
    $creadListPrec :: ReadPrec [BinPkgName]
    readListPrec :: ReadPrec [BinPkgName]
    Read, Int -> BinPkgName -> ShowS
    [BinPkgName] -> ShowS
    BinPkgName -> [Char]
    (Int -> BinPkgName -> ShowS)
    -> (BinPkgName -> [Char])
    -> ([BinPkgName] -> ShowS)
    -> Show BinPkgName
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> BinPkgName -> ShowS
    showsPrec :: Int -> BinPkgName -> ShowS
    $cshow :: BinPkgName -> [Char]
    show :: BinPkgName -> [Char]
    $cshowList :: [BinPkgName] -> ShowS
    showList :: [BinPkgName] -> ShowS
    Show, BinPkgName -> BinPkgName -> Bool
    (BinPkgName -> BinPkgName -> Bool)
    -> (BinPkgName -> BinPkgName -> Bool) -> Eq BinPkgName
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: BinPkgName -> BinPkgName -> Bool
    == :: BinPkgName -> BinPkgName -> Bool
    $c/= :: BinPkgName -> BinPkgName -> Bool
    /= :: BinPkgName -> BinPkgName -> Bool
    Eq, Eq BinPkgName
    Eq BinPkgName =>
    (BinPkgName -> BinPkgName -> Ordering)
    -> (BinPkgName -> BinPkgName -> Bool)
    -> (BinPkgName -> BinPkgName -> Bool)
    -> (BinPkgName -> BinPkgName -> Bool)
    -> (BinPkgName -> BinPkgName -> Bool)
    -> (BinPkgName -> BinPkgName -> BinPkgName)
    -> (BinPkgName -> BinPkgName -> BinPkgName)
    -> Ord BinPkgName
    BinPkgName -> BinPkgName -> Bool
    BinPkgName -> BinPkgName -> Ordering
    BinPkgName -> BinPkgName -> BinPkgName
    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 :: BinPkgName -> BinPkgName -> Ordering
    compare :: BinPkgName -> BinPkgName -> Ordering
    $c< :: BinPkgName -> BinPkgName -> Bool
    < :: BinPkgName -> BinPkgName -> Bool
    $c<= :: BinPkgName -> BinPkgName -> Bool
    <= :: BinPkgName -> BinPkgName -> Bool
    $c> :: BinPkgName -> BinPkgName -> Bool
    > :: BinPkgName -> BinPkgName -> Bool
    $c>= :: BinPkgName -> BinPkgName -> Bool
    >= :: BinPkgName -> BinPkgName -> Bool
    $cmax :: BinPkgName -> BinPkgName -> BinPkgName
    max :: BinPkgName -> BinPkgName -> BinPkgName
    $cmin :: BinPkgName -> BinPkgName -> BinPkgName
    min :: BinPkgName -> BinPkgName -> BinPkgName
    Ord, Typeable BinPkgName
    Typeable BinPkgName =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> BinPkgName -> c BinPkgName)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c BinPkgName)
    -> (BinPkgName -> Constr)
    -> (BinPkgName -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c BinPkgName))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c BinPkgName))
    -> ((forall b. Data b => b -> b) -> BinPkgName -> BinPkgName)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r)
    -> (forall u. (forall d. Data d => d -> u) -> BinPkgName -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> BinPkgName -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName)
    -> Data BinPkgName
    BinPkgName -> Constr
    BinPkgName -> DataType
    (forall b. Data b => b -> b) -> BinPkgName -> BinPkgName
    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) -> BinPkgName -> u
    forall u. (forall d. Data d => d -> u) -> BinPkgName -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BinPkgName
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BinPkgName -> c BinPkgName
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BinPkgName)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinPkgName)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BinPkgName -> c BinPkgName
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BinPkgName -> c BinPkgName
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BinPkgName
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BinPkgName
    $ctoConstr :: BinPkgName -> Constr
    toConstr :: BinPkgName -> Constr
    $cdataTypeOf :: BinPkgName -> DataType
    dataTypeOf :: BinPkgName -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BinPkgName)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BinPkgName)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinPkgName)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinPkgName)
    $cgmapT :: (forall b. Data b => b -> b) -> BinPkgName -> BinPkgName
    gmapT :: (forall b. Data b => b -> b) -> BinPkgName -> BinPkgName
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BinPkgName -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> BinPkgName -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> BinPkgName -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BinPkgName -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BinPkgName -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BinPkgName -> m BinPkgName
    Data, Typeable)

    class Pretty (PP a) => PkgName a where
        pkgNameFromString :: String -> a

    instance PkgName BinPkgName where
        pkgNameFromString :: [Char] -> BinPkgName
    pkgNameFromString = [Char] -> BinPkgName
    BinPkgName

    instance PkgName SrcPkgName where
        pkgNameFromString :: [Char] -> SrcPkgName
    pkgNameFromString = [Char] -> SrcPkgName
    SrcPkgName

    class ParseRelations a where
        -- |'parseRelations' parse a debian relation (i.e. the value of a
        -- Depends field). Return a parsec error or a value of type
        -- 'Relations'
        parseRelations :: a -> Either ParseError Relations

    -- | This needs to be indented for use in a control file: intercalate "\n     " . lines . show
    prettyRelations :: [[Relation]] -> Doc
    prettyRelations :: [[Relation]] -> Doc
    prettyRelations [[Relation]]
    xss = [Doc] -> Doc
    forall a. Monoid a => [a] -> a
    mconcat ([Doc] -> Doc) -> ([[Relation]] -> [Doc]) -> [[Relation]] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Doc -> [Doc] -> [Doc]
    forall a. a -> [a] -> [a]
    intersperse ([Char] -> Doc
    text [Char]
    "\n, ") ([Doc] -> [Doc])
    -> ([[Relation]] -> [Doc]) -> [[Relation]] -> [Doc]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Relation] -> Doc) -> [[Relation]] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    List.map [Relation] -> Doc
    prettyOrRelation ([[Relation]] -> Doc) -> [[Relation]] -> Doc
    forall a b. (a -> b) -> a -> b
    $ [[Relation]]
    xss

    prettyOrRelation :: [Relation] -> Doc
    prettyOrRelation :: [Relation] -> Doc
    prettyOrRelation [Relation]
    xs = [Doc] -> Doc
    forall a. Monoid a => [a] -> a
    mconcat ([Doc] -> Doc) -> ([Relation] -> [Doc]) -> [Relation] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Doc -> [Doc] -> [Doc]
    forall a. a -> [a] -> [a]
    intersperse ([Char] -> Doc
    text [Char]
    " | ") ([Doc] -> [Doc]) -> ([Relation] -> [Doc]) -> [Relation] -> [Doc]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Relation -> Doc) -> [Relation] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    List.map Relation -> Doc
    prettyRelation ([Relation] -> Doc) -> [Relation] -> Doc
    forall a b. (a -> b) -> a -> b
    $ [Relation]
    xs

    prettyRlists :: [RestrictionList] -> Doc
    prettyRlists :: [RestrictionList] -> Doc
    prettyRlists [RestrictionList]
    xs = [Doc] -> Doc
    forall a. Monoid a => [a] -> a
    mconcat ([Doc] -> Doc)
    -> ([RestrictionList] -> [Doc]) -> [RestrictionList] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Doc -> [Doc] -> [Doc]
    forall a. a -> [a] -> [a]
    intersperse ([Char] -> Doc
    text [Char]
    " ") ([Doc] -> [Doc])
    -> ([RestrictionList] -> [Doc]) -> [RestrictionList] -> [Doc]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (RestrictionList -> Doc) -> [RestrictionList] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    List.map RestrictionList -> Doc
    prettyRlist ([RestrictionList] -> Doc) -> [RestrictionList] -> Doc
    forall a b. (a -> b) -> a -> b
    $ [RestrictionList]
    xs
        where
            prettyRlist :: RestrictionList -> Doc
    prettyRlist RestrictionList
    r = [Char] -> Doc
    text [Char]
    "<" Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Doc] -> Doc
    forall a. Monoid a => [a] -> a
    mconcat (Doc -> [Doc] -> [Doc]
    forall a. a -> [a] -> [a]
    intersperse ([Char] -> Doc
    text ([Char]
    " ")) ([Doc] -> [Doc]) -> [Doc] -> [Doc]
    forall a b. (a -> b) -> a -> b
    $ (([Char], Bool) -> Doc) -> [([Char], Bool)] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ([Char], Bool) -> Doc
    prettyOne (RestrictionList -> [([Char], Bool)]
    forall k v. OMap k v -> [(k, v)]
    MO.assocs RestrictionList
    r)) Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    ">"
            prettyOne :: ([Char], Bool) -> Doc
    prettyOne ([Char]
    k, Bool
    v) = (if Bool
    v then Doc
    forall a. Monoid a => a
    mempty else [Char] -> Doc
    text [Char]
    "!") Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    k

    prettyRelation :: Relation -> Doc
    prettyRelation :: Relation -> Doc
    prettyRelation (RRel BinPkgName
    name Maybe VersionReq
    ver Maybe ArchitectureReq
    arch [RestrictionList]
    rlists) =
        PP BinPkgName -> Doc
    forall a. Pretty a => a -> Doc
    pretty (BinPkgName -> PP BinPkgName
    forall a. a -> PP a
    PP BinPkgName
    name) Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> Doc -> (VersionReq -> Doc) -> Maybe VersionReq -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc
    empty VersionReq -> Doc
    prettyVersionReq Maybe VersionReq
    ver Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> Doc -> (ArchitectureReq -> Doc) -> Maybe ArchitectureReq -> Doc
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc
    empty ArchitectureReq -> Doc
    prettyArchitectureReq Maybe ArchitectureReq
    arch Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> (if [RestrictionList] -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [RestrictionList]
    rlists then Doc
    empty else [Char] -> Doc
    text [Char]
    " " Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [RestrictionList] -> Doc
    prettyRlists [RestrictionList]
    rlists)

    instance Ord Relation where
        compare :: Relation -> Relation -> Ordering
    compare (RRel BinPkgName
    pkgName1 Maybe VersionReq
    mVerReq1 Maybe ArchitectureReq
    _mArch1 [RestrictionList]
    _) (RRel BinPkgName
    pkgName2 Maybe VersionReq
    mVerReq2 Maybe ArchitectureReq
    _mArch2 [RestrictionList]
    _) =
            case BinPkgName -> BinPkgName -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare BinPkgName
    pkgName1 BinPkgName
    pkgName2 of
                 Ordering
    LT -> Ordering
    LT
                 Ordering
    GT -> Ordering
    GT
                 Ordering
    EQ -> Maybe VersionReq -> Maybe VersionReq -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Maybe VersionReq
    mVerReq1 Maybe VersionReq
    mVerReq2

    data ArchitectureReq
        = ArchOnly (Set Arch)
        | ArchExcept (Set Arch)
        deriving (ArchitectureReq -> ArchitectureReq -> Bool
    (ArchitectureReq -> ArchitectureReq -> Bool)
    -> (ArchitectureReq -> ArchitectureReq -> Bool)
    -> Eq ArchitectureReq
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ArchitectureReq -> ArchitectureReq -> Bool
    == :: ArchitectureReq -> ArchitectureReq -> Bool
    $c/= :: ArchitectureReq -> ArchitectureReq -> Bool
    /= :: ArchitectureReq -> ArchitectureReq -> Bool
    Eq, Eq ArchitectureReq
    Eq ArchitectureReq =>
    (ArchitectureReq -> ArchitectureReq -> Ordering)
    -> (ArchitectureReq -> ArchitectureReq -> Bool)
    -> (ArchitectureReq -> ArchitectureReq -> Bool)
    -> (ArchitectureReq -> ArchitectureReq -> Bool)
    -> (ArchitectureReq -> ArchitectureReq -> Bool)
    -> (ArchitectureReq -> ArchitectureReq -> ArchitectureReq)
    -> (ArchitectureReq -> ArchitectureReq -> ArchitectureReq)
    -> Ord ArchitectureReq
    ArchitectureReq -> ArchitectureReq -> Bool
    ArchitectureReq -> ArchitectureReq -> Ordering
    ArchitectureReq -> ArchitectureReq -> ArchitectureReq
    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 :: ArchitectureReq -> ArchitectureReq -> Ordering
    compare :: ArchitectureReq -> ArchitectureReq -> Ordering
    $c< :: ArchitectureReq -> ArchitectureReq -> Bool
    < :: ArchitectureReq -> ArchitectureReq -> Bool
    $c<= :: ArchitectureReq -> ArchitectureReq -> Bool
    <= :: ArchitectureReq -> ArchitectureReq -> Bool
    $c> :: ArchitectureReq -> ArchitectureReq -> Bool
    > :: ArchitectureReq -> ArchitectureReq -> Bool
    $c>= :: ArchitectureReq -> ArchitectureReq -> Bool
    >= :: ArchitectureReq -> ArchitectureReq -> Bool
    $cmax :: ArchitectureReq -> ArchitectureReq -> ArchitectureReq
    max :: ArchitectureReq -> ArchitectureReq -> ArchitectureReq
    $cmin :: ArchitectureReq -> ArchitectureReq -> ArchitectureReq
    min :: ArchitectureReq -> ArchitectureReq -> ArchitectureReq
    Ord, ReadPrec [ArchitectureReq]
    ReadPrec ArchitectureReq
    Int -> ReadS ArchitectureReq
    ReadS [ArchitectureReq]
    (Int -> ReadS ArchitectureReq)
    -> ReadS [ArchitectureReq]
    -> ReadPrec ArchitectureReq
    -> ReadPrec [ArchitectureReq]
    -> Read ArchitectureReq
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS ArchitectureReq
    readsPrec :: Int -> ReadS ArchitectureReq
    $creadList :: ReadS [ArchitectureReq]
    readList :: ReadS [ArchitectureReq]
    $creadPrec :: ReadPrec ArchitectureReq
    readPrec :: ReadPrec ArchitectureReq
    $creadListPrec :: ReadPrec [ArchitectureReq]
    readListPrec :: ReadPrec [ArchitectureReq]
    Read, Int -> ArchitectureReq -> ShowS
    [ArchitectureReq] -> ShowS
    ArchitectureReq -> [Char]
    (Int -> ArchitectureReq -> ShowS)
    -> (ArchitectureReq -> [Char])
    -> ([ArchitectureReq] -> ShowS)
    -> Show ArchitectureReq
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ArchitectureReq -> ShowS
    showsPrec :: Int -> ArchitectureReq -> ShowS
    $cshow :: ArchitectureReq -> [Char]
    show :: ArchitectureReq -> [Char]
    $cshowList :: [ArchitectureReq] -> ShowS
    showList :: [ArchitectureReq] -> ShowS
    Show)

    prettyArchitectureReq :: ArchitectureReq -> Doc
    prettyArchitectureReq :: ArchitectureReq -> Doc
    prettyArchitectureReq (ArchOnly Set Arch
    arch) = [Char] -> Doc
    text [Char]
    " [" Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Doc] -> Doc
    forall a. Monoid a => [a] -> a
    mconcat ((Arch -> Doc) -> [Arch] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    List.map Arch -> Doc
    prettyArch (Set Arch -> [Arch]
    forall a. Set a -> [a]
    toList Set Arch
    arch)) Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    "]"
    prettyArchitectureReq (ArchExcept Set Arch
    arch) = [Char] -> Doc
    text [Char]
    " [" Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Doc] -> Doc
    forall a. Monoid a => [a] -> a
    mconcat ((Doc -> Doc) -> [Doc] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    List.map (([Char] -> Doc
    text [Char]
    "!") Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <>) ((Arch -> Doc) -> [Arch] -> [Doc]
    forall a b. (a -> b) -> [a] -> [b]
    List.map Arch -> Doc
    prettyArch (Set Arch -> [Arch]
    forall a. Set a -> [a]
    toList Set Arch
    arch))) Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    "]"

    data VersionReq
        = SLT DebianVersion
        | LTE DebianVersion
        | EEQ  DebianVersion
        | GRE  DebianVersion
        | SGR DebianVersion
          deriving (VersionReq -> VersionReq -> Bool
    (VersionReq -> VersionReq -> Bool)
    -> (VersionReq -> VersionReq -> Bool) -> Eq VersionReq
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: VersionReq -> VersionReq -> Bool
    == :: VersionReq -> VersionReq -> Bool
    $c/= :: VersionReq -> VersionReq -> Bool
    /= :: VersionReq -> VersionReq -> Bool
    Eq, ReadPrec [VersionReq]
    ReadPrec VersionReq
    Int -> ReadS VersionReq
    ReadS [VersionReq]
    (Int -> ReadS VersionReq)
    -> ReadS [VersionReq]
    -> ReadPrec VersionReq
    -> ReadPrec [VersionReq]
    -> Read VersionReq
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS VersionReq
    readsPrec :: Int -> ReadS VersionReq
    $creadList :: ReadS [VersionReq]
    readList :: ReadS [VersionReq]
    $creadPrec :: ReadPrec VersionReq
    readPrec :: ReadPrec VersionReq
    $creadListPrec :: ReadPrec [VersionReq]
    readListPrec :: ReadPrec [VersionReq]
    Read, Int -> VersionReq -> ShowS
    [VersionReq] -> ShowS
    VersionReq -> [Char]
    (Int -> VersionReq -> ShowS)
    -> (VersionReq -> [Char])
    -> ([VersionReq] -> ShowS)
    -> Show VersionReq
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> VersionReq -> ShowS
    showsPrec :: Int -> VersionReq -> ShowS
    $cshow :: VersionReq -> [Char]
    show :: VersionReq -> [Char]
    $cshowList :: [VersionReq] -> ShowS
    showList :: [VersionReq] -> ShowS
    Show)

    prettyVersionReq :: VersionReq -> Doc
    prettyVersionReq :: VersionReq -> Doc
    prettyVersionReq (SLT DebianVersion
    v) = [Char] -> Doc
    text [Char]
    " (<< " Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> DebianVersion -> Doc
    prettyDebianVersion DebianVersion
    v Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    ")"
    prettyVersionReq (LTE DebianVersion
    v) = [Char] -> Doc
    text [Char]
    " (<= " Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> DebianVersion -> Doc
    prettyDebianVersion DebianVersion
    v Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    ")"
    prettyVersionReq (EEQ DebianVersion
    v) = [Char] -> Doc
    text [Char]
    " (= " Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> DebianVersion -> Doc
    prettyDebianVersion DebianVersion
    v Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    ")"
    prettyVersionReq (GRE DebianVersion
    v) = [Char] -> Doc
    text [Char]
    " (>= " Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> DebianVersion -> Doc
    prettyDebianVersion DebianVersion
    v Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    ")"
    prettyVersionReq (SGR DebianVersion
    v) = [Char] -> Doc
    text [Char]
    " (>> " Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> DebianVersion -> Doc
    prettyDebianVersion DebianVersion
    v Doc -> Doc -> Doc
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Doc
    text [Char]
    ")"

    -- |The sort order is based on version number first, then on the kind of
    -- relation, sorting in the order <<, <= , ==, >= , >>
    instance Ord VersionReq where
        compare :: VersionReq -> VersionReq -> Ordering
    compare = (DebianVersion, Int) -> (DebianVersion, Int) -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare ((DebianVersion, Int) -> (DebianVersion, Int) -> Ordering)
    -> (VersionReq -> (DebianVersion, Int))
    -> VersionReq
    -> VersionReq
    -> Ordering
    forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
    `on` VersionReq -> (DebianVersion, Int)
    extr
          where extr :: VersionReq -> (DebianVersion, Int)
    extr (SLT DebianVersion
    v) = (DebianVersion
    v,Int
    0 :: Int)
                extr (LTE DebianVersion
    v) = (DebianVersion
    v,Int
    1 :: Int)
                extr (EEQ DebianVersion
    v) = (DebianVersion
    v,Int
    2 :: Int)
                extr (GRE DebianVersion
    v) = (DebianVersion
    v,Int
    3 :: Int)
                extr (SGR DebianVersion
    v) = (DebianVersion
    v,Int
    4 :: Int)

    -- |Check if a version number satisfies a version requirement.
    checkVersionReq :: Maybe VersionReq -> Maybe DebianVersion -> Bool
    checkVersionReq :: Maybe VersionReq -> Maybe DebianVersion -> Bool
    checkVersionReq Maybe VersionReq
    Nothing Maybe DebianVersion
    _ = Bool
    True
    checkVersionReq Maybe VersionReq
    _ Maybe DebianVersion
    Nothing = Bool
    False
    checkVersionReq (Just (SLT DebianVersion
    v1)) (Just DebianVersion
    v2) = DebianVersion
    v2 DebianVersion -> DebianVersion -> Bool
    forall a. Ord a => a -> a -> Bool
    < DebianVersion
    v1
    checkVersionReq (Just (LTE DebianVersion
    v1)) (Just DebianVersion
    v2) = DebianVersion
    v2 DebianVersion -> DebianVersion -> Bool
    forall a. Ord a => a -> a -> Bool
    <= DebianVersion
    v1
    checkVersionReq (Just (EEQ DebianVersion
    v1)) (Just DebianVersion
    v2) = DebianVersion
    v2 DebianVersion -> DebianVersion -> Bool
    forall a. Eq a => a -> a -> Bool
    == DebianVersion
    v1
    checkVersionReq (Just (GRE DebianVersion
    v1)) (Just DebianVersion
    v2) = DebianVersion
    v2 DebianVersion -> DebianVersion -> Bool
    forall a. Ord a => a -> a -> Bool
    >= DebianVersion
    v1
    checkVersionReq (Just (SGR DebianVersion
    v1)) (Just DebianVersion
    v2) = DebianVersion
    v2 DebianVersion -> DebianVersion -> Bool
    forall a. Ord a => a -> a -> Bool
    > DebianVersion
    v1

    instance Pretty (PP BinPkgName) where
        pretty :: PP BinPkgName -> Doc
    pretty = [Char] -> Doc
    text ([Char] -> Doc)
    -> (PP BinPkgName -> [Char]) -> PP BinPkgName -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . BinPkgName -> [Char]
    unBinPkgName (BinPkgName -> [Char])
    -> (PP BinPkgName -> BinPkgName) -> PP BinPkgName -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PP BinPkgName -> BinPkgName
    forall a. PP a -> a
    unPP

    instance Pretty (PP SrcPkgName) where
        pretty :: PP SrcPkgName -> Doc
    pretty = [Char] -> Doc
    text ([Char] -> Doc)
    -> (PP SrcPkgName -> [Char]) -> PP SrcPkgName -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SrcPkgName -> [Char]
    unSrcPkgName (SrcPkgName -> [Char])
    -> (PP SrcPkgName -> SrcPkgName) -> PP SrcPkgName -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PP SrcPkgName -> SrcPkgName
    forall a. PP a -> a
    unPP

    -- | Wrap `PP` around type synonyms that might overlap with the
    -- `Pretty [a]` instance.
    instance Pretty (PP Relations) where
        pretty :: PP [[Relation]] -> Doc
    pretty = [[Relation]] -> Doc
    prettyRelations ([[Relation]] -> Doc)
    -> (PP [[Relation]] -> [[Relation]]) -> PP [[Relation]] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PP [[Relation]] -> [[Relation]]
    forall a. PP a -> a
    unPP

    instance Pretty (PP OrRelation) where
        pretty :: PP [Relation] -> Doc
    pretty = [Relation] -> Doc
    prettyOrRelation ([Relation] -> Doc)
    -> (PP [Relation] -> [Relation]) -> PP [Relation] -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PP [Relation] -> [Relation]
    forall a. PP a -> a
    unPP

    instance Pretty (PP Relation) where
        pretty :: PP Relation -> Doc
    pretty = Relation -> Doc
    prettyRelation (Relation -> Doc)
    -> (PP Relation -> Relation) -> PP Relation -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PP Relation -> Relation
    forall a. PP a -> a
    unPP

    instance Pretty (PP VersionReq) where
        pretty :: PP VersionReq -> Doc
    pretty = VersionReq -> Doc
    prettyVersionReq (VersionReq -> Doc)
    -> (PP VersionReq -> VersionReq) -> PP VersionReq -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PP VersionReq -> VersionReq
    forall a. PP a -> a
    unPP

    instance Pretty (PP ArchitectureReq) where
        pretty :: PP ArchitectureReq -> Doc
    pretty = ArchitectureReq -> Doc
    prettyArchitectureReq (ArchitectureReq -> Doc)
    -> (PP ArchitectureReq -> ArchitectureReq)
    -> PP ArchitectureReq
    -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PP ArchitectureReq -> ArchitectureReq
    forall a. PP a -> a
    unPP