module GHC.Unit.Ppr
( UnitPprInfo (..)
)
where
import GHC.Prelude
import GHC.Data.FastString
import GHC.Utils.Outputable
import Data.Version
data UnitPprInfo = UnitPprInfo
{ UnitPprInfo -> FastString
unitPprId :: FastString
, UnitPprInfo -> String
unitPprPackageName :: String
, UnitPprInfo -> Version
unitPprPackageVersion :: Version
, UnitPprInfo -> Maybe String
unitPprComponentName :: Maybe String
}
instance Outputable UnitPprInfo where
ppr :: UnitPprInfo -> SDoc
ppr UnitPprInfo
pprinfo = forall doc. IsOutput doc => (Bool -> doc) -> doc
getPprDebug forall a b. (a -> b) -> a -> b
$ \Bool
debug ->
if Bool
debug
then forall doc. IsLine doc => FastString -> doc
ftext (UnitPprInfo -> FastString
unitPprId UnitPprInfo
pprinfo)
else forall doc. IsLine doc => String -> doc
text forall a b. (a -> b) -> a -> b
$ forall a. Monoid a => [a] -> a
mconcat
[ UnitPprInfo -> String
unitPprPackageName UnitPprInfo
pprinfo
, case UnitPprInfo -> Version
unitPprPackageVersion UnitPprInfo
pprinfo of
Version [] [] -> String
""
Version
version -> String
"-" forall a. [a] -> [a] -> [a]
++ Version -> String
showVersion Version
version
, case UnitPprInfo -> Maybe String
unitPprComponentName UnitPprInfo
pprinfo of
Maybe String
Nothing -> String
""
Just String
cname -> String
":" forall a. [a] -> [a] -> [a]
++ String
cname
]