{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.IncludeRenaming (
IncludeRenaming(..),
defaultIncludeRenaming,
isDefaultIncludeRenaming,
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Types.ModuleRenaming
import Distribution.Text
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<+>), text)
import Distribution.Compat.ReadP
data IncludeRenaming
= IncludeRenaming {
includeProvidesRn :: ModuleRenaming,
includeRequiresRn :: ModuleRenaming
}
deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)
instance Binary IncludeRenaming
defaultIncludeRenaming :: IncludeRenaming
defaultIncludeRenaming = IncludeRenaming defaultRenaming defaultRenaming
isDefaultIncludeRenaming :: IncludeRenaming -> Bool
isDefaultIncludeRenaming (IncludeRenaming p r) = isDefaultRenaming p && isDefaultRenaming r
instance Text IncludeRenaming where
disp (IncludeRenaming prov_rn req_rn) =
disp prov_rn
<+> (if isDefaultRenaming req_rn
then Disp.empty
else text "requires" <+> disp req_rn)
parse = do
prov_rn <- parse
req_rn <- (string "requires" >> skipSpaces >> parse) <++ return defaultRenaming
return (IncludeRenaming prov_rn req_rn)