never executed always true always false
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE LambdaCase #-}
3
4 module GHC.Types.PkgQual where
5
6 import GHC.Types.SourceText
7 import GHC.Unit.Types
8 import GHC.Utils.Outputable
9
10 import Data.Data
11
12 -- | Package-qualifier as it was parsed
13 data RawPkgQual
14 = NoRawPkgQual -- ^ No package qualifier
15 | RawPkgQual StringLiteral -- ^ Raw package qualifier string.
16 deriving (Data)
17
18 -- | Package-qualifier after renaming
19 --
20 -- Renaming detects if "this" or the unit-id of the home-unit was used as a
21 -- package qualifier.
22 data PkgQual
23 = NoPkgQual -- ^ No package qualifier
24 | ThisPkg UnitId -- ^ Import from home-unit
25 | OtherPkg UnitId -- ^ Import from another unit
26 deriving (Data)
27
28 instance Outputable RawPkgQual where
29 ppr = \case
30 NoRawPkgQual -> empty
31 RawPkgQual (StringLiteral st p _)
32 -> pprWithSourceText st (doubleQuotes (ftext p))
33
34 instance Outputable PkgQual where
35 ppr = \case
36 NoPkgQual -> empty
37 ThisPkg _ -> doubleQuotes (text "this")
38 OtherPkg u -> doubleQuotes (ppr u)
39
40