{-# 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
RawPkgQual -> DataType
RawPkgQual -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RawPkgQual -> m RawPkgQual
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RawPkgQual -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RawPkgQual -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> RawPkgQual -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RawPkgQual -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RawPkgQual -> r
gmapT :: (forall b. Data b => b -> b) -> RawPkgQual -> RawPkgQual
$cgmapT :: (forall b. Data b => b -> b) -> RawPkgQual -> RawPkgQual
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RawPkgQual)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RawPkgQual)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RawPkgQual)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RawPkgQual)
dataTypeOf :: RawPkgQual -> DataType
$cdataTypeOf :: RawPkgQual -> DataType
toConstr :: RawPkgQual -> Constr
$ctoConstr :: RawPkgQual -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RawPkgQual
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RawPkgQual
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RawPkgQual -> c RawPkgQual
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RawPkgQual -> c 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
PkgQual -> DataType
PkgQual -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: * -> *).
MonadPlus 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
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PkgQual -> m PkgQual
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PkgQual -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PkgQual -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> PkgQual -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PkgQual -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PkgQual -> r
gmapT :: (forall b. Data b => b -> b) -> PkgQual -> PkgQual
$cgmapT :: (forall b. Data b => b -> b) -> PkgQual -> PkgQual
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PkgQual)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PkgQual)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgQual)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PkgQual)
dataTypeOf :: PkgQual -> DataType
$cdataTypeOf :: PkgQual -> DataType
toConstr :: PkgQual -> Constr
$ctoConstr :: PkgQual -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgQual
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PkgQual
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PkgQual -> c PkgQual
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PkgQual -> c PkgQual
Data, Eq 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
min :: PkgQual -> PkgQual -> PkgQual
$cmin :: PkgQual -> PkgQual -> PkgQual
max :: PkgQual -> PkgQual -> PkgQual
$cmax :: PkgQual -> PkgQual -> PkgQual
>= :: PkgQual -> PkgQual -> Bool
$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
compare :: PkgQual -> PkgQual -> Ordering
$ccompare :: PkgQual -> PkgQual -> Ordering
Ord, PkgQual -> PkgQual -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PkgQual -> PkgQual -> Bool
$c/= :: PkgQual -> PkgQual -> Bool
== :: PkgQual -> PkgQual -> Bool
$c== :: PkgQual -> PkgQual -> Bool
Eq)

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

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