{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.IncludeRenaming (
IncludeRenaming(..),
defaultIncludeRenaming,
isDefaultIncludeRenaming,
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Types.ModuleRenaming
import qualified Distribution.Compat.CharParsing as P
import Distribution.Parsec
import Distribution.Pretty
import Text.PrettyPrint (text)
import qualified Text.PrettyPrint as Disp
data IncludeRenaming
= IncludeRenaming {
IncludeRenaming -> ModuleRenaming
includeProvidesRn :: ModuleRenaming,
IncludeRenaming -> ModuleRenaming
includeRequiresRn :: ModuleRenaming
}
deriving (Int -> IncludeRenaming -> ShowS
[IncludeRenaming] -> ShowS
IncludeRenaming -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IncludeRenaming] -> ShowS
$cshowList :: [IncludeRenaming] -> ShowS
show :: IncludeRenaming -> String
$cshow :: IncludeRenaming -> String
showsPrec :: Int -> IncludeRenaming -> ShowS
$cshowsPrec :: Int -> IncludeRenaming -> ShowS
Show, ReadPrec [IncludeRenaming]
ReadPrec IncludeRenaming
Int -> ReadS IncludeRenaming
ReadS [IncludeRenaming]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IncludeRenaming]
$creadListPrec :: ReadPrec [IncludeRenaming]
readPrec :: ReadPrec IncludeRenaming
$creadPrec :: ReadPrec IncludeRenaming
readList :: ReadS [IncludeRenaming]
$creadList :: ReadS [IncludeRenaming]
readsPrec :: Int -> ReadS IncludeRenaming
$creadsPrec :: Int -> ReadS IncludeRenaming
Read, IncludeRenaming -> IncludeRenaming -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IncludeRenaming -> IncludeRenaming -> Bool
$c/= :: IncludeRenaming -> IncludeRenaming -> Bool
== :: IncludeRenaming -> IncludeRenaming -> Bool
$c== :: IncludeRenaming -> IncludeRenaming -> Bool
Eq, Eq IncludeRenaming
IncludeRenaming -> IncludeRenaming -> Bool
IncludeRenaming -> IncludeRenaming -> Ordering
IncludeRenaming -> IncludeRenaming -> IncludeRenaming
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 :: IncludeRenaming -> IncludeRenaming -> IncludeRenaming
$cmin :: IncludeRenaming -> IncludeRenaming -> IncludeRenaming
max :: IncludeRenaming -> IncludeRenaming -> IncludeRenaming
$cmax :: IncludeRenaming -> IncludeRenaming -> IncludeRenaming
>= :: IncludeRenaming -> IncludeRenaming -> Bool
$c>= :: IncludeRenaming -> IncludeRenaming -> Bool
> :: IncludeRenaming -> IncludeRenaming -> Bool
$c> :: IncludeRenaming -> IncludeRenaming -> Bool
<= :: IncludeRenaming -> IncludeRenaming -> Bool
$c<= :: IncludeRenaming -> IncludeRenaming -> Bool
< :: IncludeRenaming -> IncludeRenaming -> Bool
$c< :: IncludeRenaming -> IncludeRenaming -> Bool
compare :: IncludeRenaming -> IncludeRenaming -> Ordering
$ccompare :: IncludeRenaming -> IncludeRenaming -> Ordering
Ord, Typeable, Typeable IncludeRenaming
IncludeRenaming -> DataType
IncludeRenaming -> Constr
(forall b. Data b => b -> b) -> IncludeRenaming -> IncludeRenaming
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) -> IncludeRenaming -> u
forall u. (forall d. Data d => d -> u) -> IncludeRenaming -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IncludeRenaming -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IncludeRenaming -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IncludeRenaming
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IncludeRenaming -> c IncludeRenaming
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IncludeRenaming)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c IncludeRenaming)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> IncludeRenaming -> m IncludeRenaming
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> IncludeRenaming -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> IncludeRenaming -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> IncludeRenaming -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> IncludeRenaming -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IncludeRenaming -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IncludeRenaming -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IncludeRenaming -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IncludeRenaming -> r
gmapT :: (forall b. Data b => b -> b) -> IncludeRenaming -> IncludeRenaming
$cgmapT :: (forall b. Data b => b -> b) -> IncludeRenaming -> IncludeRenaming
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c IncludeRenaming)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c IncludeRenaming)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IncludeRenaming)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IncludeRenaming)
dataTypeOf :: IncludeRenaming -> DataType
$cdataTypeOf :: IncludeRenaming -> DataType
toConstr :: IncludeRenaming -> Constr
$ctoConstr :: IncludeRenaming -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IncludeRenaming
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IncludeRenaming
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IncludeRenaming -> c IncludeRenaming
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IncludeRenaming -> c IncludeRenaming
Data, forall x. Rep IncludeRenaming x -> IncludeRenaming
forall x. IncludeRenaming -> Rep IncludeRenaming x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IncludeRenaming x -> IncludeRenaming
$cfrom :: forall x. IncludeRenaming -> Rep IncludeRenaming x
Generic)
instance Binary IncludeRenaming
instance Structured IncludeRenaming
instance NFData IncludeRenaming where rnf :: IncludeRenaming -> ()
rnf = forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
defaultIncludeRenaming :: IncludeRenaming
defaultIncludeRenaming :: IncludeRenaming
defaultIncludeRenaming = ModuleRenaming -> ModuleRenaming -> IncludeRenaming
IncludeRenaming ModuleRenaming
defaultRenaming ModuleRenaming
defaultRenaming
isDefaultIncludeRenaming :: IncludeRenaming -> Bool
isDefaultIncludeRenaming :: IncludeRenaming -> Bool
isDefaultIncludeRenaming (IncludeRenaming ModuleRenaming
p ModuleRenaming
r) = ModuleRenaming -> Bool
isDefaultRenaming ModuleRenaming
p Bool -> Bool -> Bool
&& ModuleRenaming -> Bool
isDefaultRenaming ModuleRenaming
r
instance Pretty IncludeRenaming where
pretty :: IncludeRenaming -> Doc
pretty (IncludeRenaming ModuleRenaming
prov_rn ModuleRenaming
req_rn) =
forall a. Pretty a => a -> Doc
pretty ModuleRenaming
prov_rn
Doc -> Doc -> Doc
<+> (if ModuleRenaming -> Bool
isDefaultRenaming ModuleRenaming
req_rn
then Doc
Disp.empty
else String -> Doc
text String
"requires" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pretty ModuleRenaming
req_rn)
instance Parsec IncludeRenaming where
parsec :: forall (m :: * -> *). CabalParsing m => m IncludeRenaming
parsec = do
ModuleRenaming
prov_rn <- forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec
ModuleRenaming
req_rn <- forall (m :: * -> *) a. Alternative m => a -> m a -> m a
P.option ModuleRenaming
defaultRenaming forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
P.try forall a b. (a -> b) -> a -> b
$ do
forall (m :: * -> *). CharParsing m => m ()
P.spaces
String
_ <- forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"requires"
forall (m :: * -> *). CharParsing m => m ()
P.spaces
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleRenaming -> ModuleRenaming -> IncludeRenaming
IncludeRenaming ModuleRenaming
prov_rn ModuleRenaming
req_rn)