never executed always true always false
1 -- | Unit identifier pretty-printing
2 module GHC.Unit.Ppr
3 ( UnitPprInfo (..)
4 )
5 where
6
7 import GHC.Prelude
8 import GHC.Data.FastString
9 import GHC.Utils.Outputable
10 import Data.Version
11
12 -- | Subset of UnitInfo: just enough to pretty-print a unit-id
13 --
14 -- Instead of printing the unit-id which may contain a hash, we print:
15 -- package-version:componentname
16 --
17 data UnitPprInfo = UnitPprInfo
18 { unitPprId :: FastString -- ^ Identifier
19 , unitPprPackageName :: String -- ^ Source package name
20 , unitPprPackageVersion :: Version -- ^ Source package version
21 , unitPprComponentName :: Maybe String -- ^ Component name
22 }
23
24 instance Outputable UnitPprInfo where
25 ppr pprinfo = getPprDebug $ \debug ->
26 if debug
27 then ftext (unitPprId pprinfo)
28 else text $ mconcat
29 [ unitPprPackageName pprinfo
30 , case unitPprPackageVersion pprinfo of
31 Version [] [] -> ""
32 version -> "-" ++ showVersion version
33 , case unitPprComponentName pprinfo of
34 Nothing -> ""
35 Just cname -> ":" ++ cname
36 ]