{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE LambdaCase #-}

module GHC.Types.PkgQual where

import GHC.Prelude
import GHC.Types.SourceText
import GHC.Unit.Types
import GHC.Utils.Outputable

import Data.Data

-- | Package-qualifier as it was parsed
data RawPkgQual
  = NoRawPkgQual             -- ^ No package qualifier
  | RawPkgQual StringLiteral -- ^ Raw package qualifier string.
  deriving (Typeable RawPkgQual
Typeable RawPkgQual
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RawPkgQual -> c RawPkgQual)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RawPkgQual)
-> (RawPkgQual -> Constr)
-> (RawPkgQual -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RawPkgQual))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c RawPkgQual))
-> ((forall b. Data b => b -> b) -> RawPkgQual -> RawPkgQual)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r)
-> (forall u. (forall d. Data d => d -> u) -> RawPkgQual -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RawPkgQual -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual)
-> Data RawPkgQual
RawPkgQual -> Constr
RawPkgQual -> DataType
(forall b. Data b => b -> b) -> RawPkgQual -> RawPkgQual
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) -> RawPkgQual -> u
forall u. (forall d. Data d => d -> u) -> RawPkgQual -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RawPkgQual
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RawPkgQual -> c RawPkgQual
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RawPkgQual)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RawPkgQual)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RawPkgQual -> c RawPkgQual
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RawPkgQual -> c RawPkgQual
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RawPkgQual
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RawPkgQual
$ctoConstr :: RawPkgQual -> Constr
toConstr :: RawPkgQual -> Constr
$cdataTypeOf :: RawPkgQual -> DataType
dataTypeOf :: RawPkgQual -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RawPkgQual)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RawPkgQual)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RawPkgQual)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RawPkgQual)
$cgmapT :: (forall b. Data b => b -> b) -> RawPkgQual -> RawPkgQual
gmapT :: (forall b. Data b => b -> b) -> RawPkgQual -> RawPkgQual
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RawPkgQual -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RawPkgQual -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RawPkgQual -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RawPkgQual -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
Data)

-- | Package-qualifier after renaming
--
-- Renaming detects if "this" or the unit-id of the home-unit was used as a
-- package qualifier.
data PkgQual
  = NoPkgQual       -- ^ No package qualifier
  | ThisPkg  UnitId -- ^ Import from home-unit
  | OtherPkg UnitId -- ^ Import from another unit
  deriving (Typeable PkgQual
Typeable PkgQual
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> PkgQual -> c PkgQual)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PkgQual)
-> (PkgQual -> Constr)
-> (PkgQual -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PkgQual))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PkgQual))
-> ((forall b. Data b => b -> b) -> PkgQual -> PkgQual)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PkgQual -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PkgQual -> r)
-> (forall u. (forall d. Data d => d -> u) -> PkgQual -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PkgQual -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PkgQual -> m PkgQual)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PkgQual -> m PkgQual)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PkgQual -> m PkgQual)
-> Data PkgQual
PkgQual -> Constr
PkgQual -> DataType
(forall b. Data b => b -> b) -> PkgQual -> PkgQual
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) -> PkgQual -> u
forall u. (forall d. Data d => d -> u) -> PkgQual -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgQual
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PkgQual -> c PkgQual
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgQual)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PkgQual)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PkgQual -> c PkgQual
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PkgQual -> c PkgQual
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgQual
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgQual
$ctoConstr :: PkgQual -> Constr
toConstr :: PkgQual -> Constr
$cdataTypeOf :: PkgQual -> DataType
dataTypeOf :: PkgQual -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgQual)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgQual)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PkgQual)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PkgQual)
$cgmapT :: (forall b. Data b => b -> b) -> PkgQual -> PkgQual
gmapT :: (forall b. Data b => b -> b) -> PkgQual -> PkgQual
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PkgQual -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PkgQual -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PkgQual -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PkgQual -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
Data, Eq PkgQual
Eq PkgQual
-> (PkgQual -> PkgQual -> Ordering)
-> (PkgQual -> PkgQual -> Bool)
-> (PkgQual -> PkgQual -> Bool)
-> (PkgQual -> PkgQual -> Bool)
-> (PkgQual -> PkgQual -> Bool)
-> (PkgQual -> PkgQual -> PkgQual)
-> (PkgQual -> PkgQual -> PkgQual)
-> Ord PkgQual
PkgQual -> PkgQual -> Bool
PkgQual -> PkgQual -> Ordering
PkgQual -> PkgQual -> PkgQual
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
$ccompare :: PkgQual -> PkgQual -> Ordering
compare :: PkgQual -> PkgQual -> Ordering
$c< :: PkgQual -> PkgQual -> Bool
< :: PkgQual -> PkgQual -> Bool
$c<= :: PkgQual -> PkgQual -> Bool
<= :: PkgQual -> PkgQual -> Bool
$c> :: PkgQual -> PkgQual -> Bool
> :: PkgQual -> PkgQual -> Bool
$c>= :: PkgQual -> PkgQual -> Bool
>= :: PkgQual -> PkgQual -> Bool
$cmax :: PkgQual -> PkgQual -> PkgQual
max :: PkgQual -> PkgQual -> PkgQual
$cmin :: PkgQual -> PkgQual -> PkgQual
min :: PkgQual -> PkgQual -> PkgQual
Ord, PkgQual -> PkgQual -> Bool
(PkgQual -> PkgQual -> Bool)
-> (PkgQual -> PkgQual -> Bool) -> Eq PkgQual
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PkgQual -> PkgQual -> Bool
== :: PkgQual -> PkgQual -> Bool
$c/= :: PkgQual -> PkgQual -> Bool
/= :: PkgQual -> PkgQual -> Bool
Eq)

instance Outputable RawPkgQual where
  ppr :: RawPkgQual -> SDoc
ppr = \case
    RawPkgQual
NoRawPkgQual -> SDoc
empty
    RawPkgQual (StringLiteral SourceText
st FastString
p Maybe RealSrcSpan
_)
      -> SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st (SDoc -> SDoc
doubleQuotes (FastString -> SDoc
ftext FastString
p))

instance Outputable PkgQual where
  ppr :: PkgQual -> SDoc
ppr = \case
    PkgQual
NoPkgQual  -> SDoc
empty
    ThisPkg UnitId
u  -> SDoc -> SDoc
doubleQuotes (UnitId -> SDoc
forall a. Outputable a => a -> SDoc
ppr UnitId
u)
    OtherPkg UnitId
u -> SDoc -> SDoc
doubleQuotes (UnitId -> SDoc
forall a. Outputable a => a -> SDoc
ppr UnitId
u)