{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module GHC.Hs.ImpExp
( module Language.Haskell.Syntax.ImpExp
, module GHC.Hs.ImpExp
) where
import GHC.Prelude
import GHC.Types.SourceText ( SourceText(..) )
import GHC.Types.FieldLabel ( FieldLabel )
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Types.SrcLoc
import GHC.Parser.Annotation
import GHC.Hs.Extension
import GHC.Types.Name
import GHC.Types.PkgQual
import Data.Data
import Data.Maybe
import Language.Haskell.Syntax.Extension
import Language.Haskell.Syntax.Module.Name
import Language.Haskell.Syntax.ImpExp
type instance Anno (ImportDecl (GhcPass p)) = SrcSpanAnnA
importDeclQualifiedStyle :: Maybe EpaLocation
-> Maybe EpaLocation
-> (Maybe EpaLocation, ImportDeclQualifiedStyle)
importDeclQualifiedStyle :: Maybe EpaLocation
-> Maybe EpaLocation
-> (Maybe EpaLocation, ImportDeclQualifiedStyle)
importDeclQualifiedStyle Maybe EpaLocation
mPre Maybe EpaLocation
mPost =
if forall a. Maybe a -> Bool
isJust Maybe EpaLocation
mPre then (Maybe EpaLocation
mPre, ImportDeclQualifiedStyle
QualifiedPre)
else if forall a. Maybe a -> Bool
isJust Maybe EpaLocation
mPost then (Maybe EpaLocation
mPost,ImportDeclQualifiedStyle
QualifiedPost) else (forall a. Maybe a
Nothing, ImportDeclQualifiedStyle
NotQualified)
isImportDeclQualified :: ImportDeclQualifiedStyle -> Bool
isImportDeclQualified :: ImportDeclQualifiedStyle -> Bool
isImportDeclQualified ImportDeclQualifiedStyle
NotQualified = Bool
False
isImportDeclQualified ImportDeclQualifiedStyle
_ = Bool
True
type instance ImportDeclPkgQual GhcPs = RawPkgQual
type instance ImportDeclPkgQual GhcRn = PkgQual
type instance ImportDeclPkgQual GhcTc = PkgQual
type instance XCImportDecl GhcPs = XImportDeclPass
type instance XCImportDecl GhcRn = XImportDeclPass
type instance XCImportDecl GhcTc = DataConCantHappen
data XImportDeclPass = XImportDeclPass
{ XImportDeclPass -> EpAnn EpAnnImportDecl
ideclAnn :: EpAnn EpAnnImportDecl
, XImportDeclPass -> SourceText
ideclSourceText :: SourceText
, XImportDeclPass -> Bool
ideclImplicit :: Bool
}
deriving (Typeable XImportDeclPass
XImportDeclPass -> DataType
XImportDeclPass -> Constr
(forall b. Data b => b -> b) -> XImportDeclPass -> XImportDeclPass
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) -> XImportDeclPass -> u
forall u. (forall d. Data d => d -> u) -> XImportDeclPass -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> XImportDeclPass -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> XImportDeclPass -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XImportDeclPass
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> XImportDeclPass -> c XImportDeclPass
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XImportDeclPass)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c XImportDeclPass)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> XImportDeclPass -> m XImportDeclPass
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> XImportDeclPass -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> XImportDeclPass -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> XImportDeclPass -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> XImportDeclPass -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> XImportDeclPass -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> XImportDeclPass -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> XImportDeclPass -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> XImportDeclPass -> r
gmapT :: (forall b. Data b => b -> b) -> XImportDeclPass -> XImportDeclPass
$cgmapT :: (forall b. Data b => b -> b) -> XImportDeclPass -> XImportDeclPass
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c XImportDeclPass)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c XImportDeclPass)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XImportDeclPass)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XImportDeclPass)
dataTypeOf :: XImportDeclPass -> DataType
$cdataTypeOf :: XImportDeclPass -> DataType
toConstr :: XImportDeclPass -> Constr
$ctoConstr :: XImportDeclPass -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XImportDeclPass
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XImportDeclPass
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> XImportDeclPass -> c XImportDeclPass
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> XImportDeclPass -> c XImportDeclPass
Data)
type instance XXImportDecl (GhcPass _) = DataConCantHappen
type instance Anno ModuleName = SrcSpanAnnA
type instance Anno [LocatedA (IE (GhcPass p))] = SrcSpanAnnL
deriving instance Data (IEWrappedName GhcPs)
deriving instance Data (IEWrappedName GhcRn)
deriving instance Data (IEWrappedName GhcTc)
deriving instance Eq (IEWrappedName GhcPs)
deriving instance Eq (IEWrappedName GhcRn)
deriving instance Eq (IEWrappedName GhcTc)
data EpAnnImportDecl = EpAnnImportDecl
{ EpAnnImportDecl -> EpaLocation
importDeclAnnImport :: EpaLocation
, EpAnnImportDecl -> Maybe (EpaLocation, EpaLocation)
importDeclAnnPragma :: Maybe (EpaLocation, EpaLocation)
, EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnSafe :: Maybe EpaLocation
, EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnQualified :: Maybe EpaLocation
, EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnPackage :: Maybe EpaLocation
, EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnAs :: Maybe EpaLocation
} deriving (Typeable EpAnnImportDecl
EpAnnImportDecl -> DataType
EpAnnImportDecl -> Constr
(forall b. Data b => b -> b) -> EpAnnImportDecl -> EpAnnImportDecl
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) -> EpAnnImportDecl -> u
forall u. (forall d. Data d => d -> u) -> EpAnnImportDecl -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnImportDecl -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnImportDecl -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnImportDecl
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnImportDecl -> c EpAnnImportDecl
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnImportDecl)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpAnnImportDecl)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> EpAnnImportDecl -> m EpAnnImportDecl
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> EpAnnImportDecl -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> EpAnnImportDecl -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EpAnnImportDecl -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EpAnnImportDecl -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnImportDecl -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnImportDecl -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnImportDecl -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EpAnnImportDecl -> r
gmapT :: (forall b. Data b => b -> b) -> EpAnnImportDecl -> EpAnnImportDecl
$cgmapT :: (forall b. Data b => b -> b) -> EpAnnImportDecl -> EpAnnImportDecl
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpAnnImportDecl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EpAnnImportDecl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnImportDecl)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EpAnnImportDecl)
dataTypeOf :: EpAnnImportDecl -> DataType
$cdataTypeOf :: EpAnnImportDecl -> DataType
toConstr :: EpAnnImportDecl -> Constr
$ctoConstr :: EpAnnImportDecl -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnImportDecl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EpAnnImportDecl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnImportDecl -> c EpAnnImportDecl
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EpAnnImportDecl -> c EpAnnImportDecl
Data)
simpleImportDecl :: ModuleName -> ImportDecl GhcPs
simpleImportDecl :: ModuleName -> ImportDecl GhcPs
simpleImportDecl ModuleName
mn = ImportDecl {
ideclExt :: XCImportDecl GhcPs
ideclExt = EpAnn EpAnnImportDecl -> SourceText -> Bool -> XImportDeclPass
XImportDeclPass forall a. EpAnn a
noAnn SourceText
NoSourceText Bool
False,
ideclName :: XRec GhcPs ModuleName
ideclName = forall a an. a -> LocatedAn an a
noLocA ModuleName
mn,
ideclPkgQual :: ImportDeclPkgQual GhcPs
ideclPkgQual = RawPkgQual
NoRawPkgQual,
ideclSource :: IsBootInterface
ideclSource = IsBootInterface
NotBoot,
ideclSafe :: Bool
ideclSafe = Bool
False,
ideclQualified :: ImportDeclQualifiedStyle
ideclQualified = ImportDeclQualifiedStyle
NotQualified,
ideclAs :: Maybe (XRec GhcPs ModuleName)
ideclAs = forall a. Maybe a
Nothing,
ideclImportList :: Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
ideclImportList = forall a. Maybe a
Nothing
}
instance (OutputableBndrId p
, Outputable (Anno (IE (GhcPass p)))
, Outputable (ImportDeclPkgQual (GhcPass p)))
=> Outputable (ImportDecl (GhcPass p)) where
ppr :: ImportDecl (GhcPass p) -> SDoc
ppr (ImportDecl { ideclExt :: forall pass. ImportDecl pass -> XCImportDecl pass
ideclExt = XCImportDecl (GhcPass p)
impExt, ideclName :: forall pass. ImportDecl pass -> XRec pass ModuleName
ideclName = XRec (GhcPass p) ModuleName
mod'
, ideclPkgQual :: forall pass. ImportDecl pass -> ImportDeclPkgQual pass
ideclPkgQual = ImportDeclPkgQual (GhcPass p)
pkg
, ideclSource :: forall pass. ImportDecl pass -> IsBootInterface
ideclSource = IsBootInterface
from, ideclSafe :: forall pass. ImportDecl pass -> Bool
ideclSafe = Bool
safe
, ideclQualified :: forall pass. ImportDecl pass -> ImportDeclQualifiedStyle
ideclQualified = ImportDeclQualifiedStyle
qual
, ideclAs :: forall pass. ImportDecl pass -> Maybe (XRec pass ModuleName)
ideclAs = Maybe (XRec (GhcPass p) ModuleName)
as, ideclImportList :: forall pass.
ImportDecl pass
-> Maybe (ImportListInterpretation, XRec pass [LIE pass])
ideclImportList = Maybe
(ImportListInterpretation, XRec (GhcPass p) [LIE (GhcPass p)])
spec })
= SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => [doc] -> doc
hsep [forall doc. IsLine doc => String -> doc
text String
"import", XCImportDecl (GhcPass p) -> IsBootInterface -> SDoc
ppr_imp XCImportDecl (GhcPass p)
impExt IsBootInterface
from, XCImportDecl (GhcPass p) -> SDoc
pp_implicit XCImportDecl (GhcPass p)
impExt, forall {doc}. IsLine doc => Bool -> doc
pp_safe Bool
safe,
forall {doc}. IsLine doc => ImportDeclQualifiedStyle -> Bool -> doc
pp_qual ImportDeclQualifiedStyle
qual Bool
False, forall a. Outputable a => a -> SDoc
ppr ImportDeclPkgQual (GhcPass p)
pkg, forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) ModuleName
mod', forall {doc}. IsLine doc => ImportDeclQualifiedStyle -> Bool -> doc
pp_qual ImportDeclQualifiedStyle
qual Bool
True, forall {a}. Outputable a => Maybe a -> SDoc
pp_as Maybe (XRec (GhcPass p) ModuleName)
as])
Int
4 (forall {a} {l}.
Outputable a =>
Maybe (ImportListInterpretation, GenLocated l [a]) -> SDoc
pp_spec Maybe
(ImportListInterpretation, XRec (GhcPass p) [LIE (GhcPass p)])
spec)
where
pp_implicit :: XCImportDecl (GhcPass p) -> SDoc
pp_implicit XCImportDecl (GhcPass p)
ext =
let implicit :: Bool
implicit = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs | XImportDeclPass { ideclImplicit :: XImportDeclPass -> Bool
ideclImplicit = Bool
implicit } <- XCImportDecl (GhcPass p)
ext -> Bool
implicit
GhcPass p
GhcRn | XImportDeclPass { ideclImplicit :: XImportDeclPass -> Bool
ideclImplicit = Bool
implicit } <- XCImportDecl (GhcPass p)
ext -> Bool
implicit
GhcPass p
GhcTc -> forall a. DataConCantHappen -> a
dataConCantHappen XCImportDecl (GhcPass p)
ext
in if Bool
implicit then forall doc. IsLine doc => String -> doc
text String
"(implicit)"
else forall doc. IsOutput doc => doc
empty
pp_qual :: ImportDeclQualifiedStyle -> Bool -> doc
pp_qual ImportDeclQualifiedStyle
QualifiedPre Bool
False = forall doc. IsLine doc => String -> doc
text String
"qualified"
pp_qual ImportDeclQualifiedStyle
QualifiedPost Bool
True = forall doc. IsLine doc => String -> doc
text String
"qualified"
pp_qual ImportDeclQualifiedStyle
QualifiedPre Bool
True = forall doc. IsOutput doc => doc
empty
pp_qual ImportDeclQualifiedStyle
QualifiedPost Bool
False = forall doc. IsOutput doc => doc
empty
pp_qual ImportDeclQualifiedStyle
NotQualified Bool
_ = forall doc. IsOutput doc => doc
empty
pp_safe :: Bool -> doc
pp_safe Bool
False = forall doc. IsOutput doc => doc
empty
pp_safe Bool
True = forall doc. IsLine doc => String -> doc
text String
"safe"
pp_as :: Maybe a -> SDoc
pp_as Maybe a
Nothing = forall doc. IsOutput doc => doc
empty
pp_as (Just a
a) = forall doc. IsLine doc => String -> doc
text String
"as" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr a
a
ppr_imp :: XCImportDecl (GhcPass p) -> IsBootInterface -> SDoc
ppr_imp XCImportDecl (GhcPass p)
ext IsBootInterface
IsBoot =
let mSrcText :: SourceText
mSrcText = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs | XImportDeclPass { ideclSourceText :: XImportDeclPass -> SourceText
ideclSourceText = SourceText
mst } <- XCImportDecl (GhcPass p)
ext -> SourceText
mst
GhcPass p
GhcRn | XImportDeclPass { ideclSourceText :: XImportDeclPass -> SourceText
ideclSourceText = SourceText
mst } <- XCImportDecl (GhcPass p)
ext -> SourceText
mst
GhcPass p
GhcTc -> forall a. DataConCantHappen -> a
dataConCantHappen XCImportDecl (GhcPass p)
ext
in case SourceText
mSrcText of
SourceText
NoSourceText -> forall doc. IsLine doc => String -> doc
text String
"{-# SOURCE #-}"
SourceText String
src -> forall doc. IsLine doc => String -> doc
text String
src forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
ppr_imp XCImportDecl (GhcPass p)
_ IsBootInterface
NotBoot = forall doc. IsOutput doc => doc
empty
pp_spec :: Maybe (ImportListInterpretation, GenLocated l [a]) -> SDoc
pp_spec Maybe (ImportListInterpretation, GenLocated l [a])
Nothing = forall doc. IsOutput doc => doc
empty
pp_spec (Just (ImportListInterpretation
Exactly, (L l
_ [a]
ies))) = forall {a}. Outputable a => [a] -> SDoc
ppr_ies [a]
ies
pp_spec (Just (ImportListInterpretation
EverythingBut, (L l
_ [a]
ies))) = forall doc. IsLine doc => String -> doc
text String
"hiding" forall doc. IsLine doc => doc -> doc -> doc
<+> forall {a}. Outputable a => [a] -> SDoc
ppr_ies [a]
ies
ppr_ies :: [a] -> SDoc
ppr_ies [] = forall doc. IsLine doc => String -> doc
text String
"()"
ppr_ies [a]
ies = forall doc. IsLine doc => Char -> doc
char Char
'(' forall doc. IsLine doc => doc -> doc -> doc
<+> forall {a}. Outputable a => [a] -> SDoc
interpp'SP [a]
ies forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
')'
type instance XIEName (GhcPass _) = NoExtField
type instance XIEPattern (GhcPass _) = EpaLocation
type instance XIEType (GhcPass _) = EpaLocation
type instance XXIEWrappedName (GhcPass _) = DataConCantHappen
type instance Anno (IEWrappedName (GhcPass _)) = SrcSpanAnnA
type instance Anno (IE (GhcPass p)) = SrcSpanAnnA
type instance XIEVar GhcPs = NoExtField
type instance XIEVar GhcRn = NoExtField
type instance XIEVar GhcTc = NoExtField
type instance XIEThingAbs (GhcPass _) = EpAnn [AddEpAnn]
type instance XIEThingAll (GhcPass _) = EpAnn [AddEpAnn]
type instance XIEThingWith (GhcPass 'Parsed) = EpAnn [AddEpAnn]
type instance XIEThingWith (GhcPass 'Renamed) = [Located FieldLabel]
type instance XIEThingWith (GhcPass 'Typechecked) = NoExtField
type instance XIEModuleContents GhcPs = EpAnn [AddEpAnn]
type instance XIEModuleContents GhcRn = NoExtField
type instance XIEModuleContents GhcTc = NoExtField
type instance XIEGroup (GhcPass _) = NoExtField
type instance XIEDoc (GhcPass _) = NoExtField
type instance XIEDocNamed (GhcPass _) = NoExtField
type instance XXIE (GhcPass _) = DataConCantHappen
type instance Anno (LocatedA (IE (GhcPass p))) = SrcSpanAnnA
ieName :: IE (GhcPass p) -> IdP (GhcPass p)
ieName :: forall (p :: Pass). IE (GhcPass p) -> IdP (GhcPass p)
ieName (IEVar XIEVar (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n)) = forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n
ieName (IEThingAbs XIEThingAbs (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n)) = forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n
ieName (IEThingWith XIEThingWith (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n) IEWildcard
_ [LIEWrappedName (GhcPass p)]
_) = forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n
ieName (IEThingAll XIEThingAll (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n)) = forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n
ieName IE (GhcPass p)
_ = forall a. HasCallStack => String -> a
panic String
"ieName failed pattern match!"
ieNames :: IE (GhcPass p) -> [IdP (GhcPass p)]
ieNames :: forall (p :: Pass). IE (GhcPass p) -> [IdP (GhcPass p)]
ieNames (IEVar XIEVar (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n) ) = [forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n]
ieNames (IEThingAbs XIEThingAbs (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n) ) = [forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n]
ieNames (IEThingAll XIEThingAll (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n) ) = [forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n]
ieNames (IEThingWith XIEThingWith (GhcPass p)
_ (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n) IEWildcard
_ [LIEWrappedName (GhcPass p)]
ns) = forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n
forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LIEWrappedName (GhcPass p)]
ns
ieNames (IEModuleContents {}) = []
ieNames (IEGroup {}) = []
ieNames (IEDoc {}) = []
ieNames (IEDocNamed {}) = []
ieWrappedLName :: IEWrappedName (GhcPass p) -> LIdP (GhcPass p)
ieWrappedLName :: forall (p :: Pass). IEWrappedName (GhcPass p) -> LIdP (GhcPass p)
ieWrappedLName (IEName XIEName (GhcPass p)
_ (L Anno (IdGhcP p)
l IdGhcP p
n)) = forall l e. l -> e -> GenLocated l e
L Anno (IdGhcP p)
l IdGhcP p
n
ieWrappedLName (IEPattern XIEPattern (GhcPass p)
_ (L Anno (IdGhcP p)
l IdGhcP p
n)) = forall l e. l -> e -> GenLocated l e
L Anno (IdGhcP p)
l IdGhcP p
n
ieWrappedLName (IEType XIEType (GhcPass p)
_ (L Anno (IdGhcP p)
l IdGhcP p
n)) = forall l e. l -> e -> GenLocated l e
L Anno (IdGhcP p)
l IdGhcP p
n
ieWrappedName :: IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName :: forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName = forall l e. GenLocated l e -> e
unLoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: Pass). IEWrappedName (GhcPass p) -> LIdP (GhcPass p)
ieWrappedLName
lieWrappedName :: LIEWrappedName (GhcPass p) -> IdP (GhcPass p)
lieWrappedName :: forall (p :: Pass). LIEWrappedName (GhcPass p) -> IdP (GhcPass p)
lieWrappedName (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n) = forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
n
ieLWrappedName :: LIEWrappedName (GhcPass p) -> LIdP (GhcPass p)
ieLWrappedName :: forall (p :: Pass). LIEWrappedName (GhcPass p) -> LIdP (GhcPass p)
ieLWrappedName (L SrcSpanAnnA
_ IEWrappedName (GhcPass p)
n) = forall (p :: Pass). IEWrappedName (GhcPass p) -> LIdP (GhcPass p)
ieWrappedLName IEWrappedName (GhcPass p)
n
replaceWrappedName :: IEWrappedName GhcPs -> IdP GhcRn -> IEWrappedName GhcRn
replaceWrappedName :: IEWrappedName GhcPs -> IdP GhcRn -> IEWrappedName GhcRn
replaceWrappedName (IEName XIEName GhcPs
x (L SrcSpanAnnN
l RdrName
_)) IdP GhcRn
n = forall p. XIEName p -> LIdP p -> IEWrappedName p
IEName XIEName GhcPs
x (forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l IdP GhcRn
n)
replaceWrappedName (IEPattern XIEPattern GhcPs
r (L SrcSpanAnnN
l RdrName
_)) IdP GhcRn
n = forall p. XIEPattern p -> LIdP p -> IEWrappedName p
IEPattern XIEPattern GhcPs
r (forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l IdP GhcRn
n)
replaceWrappedName (IEType XIEType GhcPs
r (L SrcSpanAnnN
l RdrName
_)) IdP GhcRn
n = forall p. XIEType p -> LIdP p -> IEWrappedName p
IEType XIEType GhcPs
r (forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
l IdP GhcRn
n)
replaceLWrappedName :: LIEWrappedName GhcPs -> IdP GhcRn -> LIEWrappedName GhcRn
replaceLWrappedName :: LIEWrappedName GhcPs -> IdP GhcRn -> LIEWrappedName GhcRn
replaceLWrappedName (L SrcSpanAnnA
l IEWrappedName GhcPs
n) IdP GhcRn
n' = forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
l (IEWrappedName GhcPs -> IdP GhcRn -> IEWrappedName GhcRn
replaceWrappedName IEWrappedName GhcPs
n IdP GhcRn
n')
instance OutputableBndrId p => Outputable (IE (GhcPass p)) where
ppr :: IE (GhcPass p) -> SDoc
ppr (IEVar XIEVar (GhcPass p)
_ LIEWrappedName (GhcPass p)
var) = forall a. Outputable a => a -> SDoc
ppr (forall l e. GenLocated l e -> e
unLoc LIEWrappedName (GhcPass p)
var)
ppr (IEThingAbs XIEThingAbs (GhcPass p)
_ LIEWrappedName (GhcPass p)
thing) = forall a. Outputable a => a -> SDoc
ppr (forall l e. GenLocated l e -> e
unLoc LIEWrappedName (GhcPass p)
thing)
ppr (IEThingAll XIEThingAll (GhcPass p)
_ LIEWrappedName (GhcPass p)
thing) = forall doc. IsLine doc => [doc] -> doc
hcat [forall a. Outputable a => a -> SDoc
ppr (forall l e. GenLocated l e -> e
unLoc LIEWrappedName (GhcPass p)
thing), forall doc. IsLine doc => String -> doc
text String
"(..)"]
ppr (IEThingWith XIEThingWith (GhcPass p)
flds LIEWrappedName (GhcPass p)
thing IEWildcard
wc [LIEWrappedName (GhcPass p)]
withs)
= forall a. Outputable a => a -> SDoc
ppr (forall l e. GenLocated l e -> e
unLoc LIEWrappedName (GhcPass p)
thing) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc -> doc
parens (forall doc. IsLine doc => [doc] -> doc
fsep (forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma
([SDoc]
ppWiths forall a. [a] -> [a] -> [a]
++ [SDoc]
ppFields) ))
where
ppWiths :: [SDoc]
ppWiths =
case IEWildcard
wc of
IEWildcard
NoIEWildcard ->
forall a b. (a -> b) -> [a] -> [b]
map (forall a. Outputable a => a -> SDoc
ppr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LIEWrappedName (GhcPass p)]
withs
IEWildcard Int
pos ->
let ([SDoc]
bs, [SDoc]
as) = forall a. Int -> [a] -> ([a], [a])
splitAt Int
pos (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Outputable a => a -> SDoc
ppr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LIEWrappedName (GhcPass p)]
withs)
in [SDoc]
bs forall a. [a] -> [a] -> [a]
++ [forall doc. IsLine doc => String -> doc
text String
".."] forall a. [a] -> [a] -> [a]
++ [SDoc]
as
ppFields :: [SDoc]
ppFields =
case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcRn -> forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr XIEThingWith (GhcPass p)
flds
GhcPass p
_ -> []
ppr (IEModuleContents XIEModuleContents (GhcPass p)
_ XRec (GhcPass p) ModuleName
mod')
= forall doc. IsLine doc => String -> doc
text String
"module" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) ModuleName
mod'
ppr (IEGroup XIEGroup (GhcPass p)
_ Int
n LHsDoc (GhcPass p)
_) = forall doc. IsLine doc => String -> doc
text (String
"<IEGroup: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Int
n forall a. [a] -> [a] -> [a]
++ String
">")
ppr (IEDoc XIEDoc (GhcPass p)
_ LHsDoc (GhcPass p)
doc) = forall a. Outputable a => a -> SDoc
ppr LHsDoc (GhcPass p)
doc
ppr (IEDocNamed XIEDocNamed (GhcPass p)
_ String
string) = forall doc. IsLine doc => String -> doc
text (String
"<IEDocNamed: " forall a. [a] -> [a] -> [a]
++ String
string forall a. [a] -> [a] -> [a]
++ String
">")
instance (HasOccName (IdP (GhcPass p)), OutputableBndrId p) => HasOccName (IEWrappedName (GhcPass p)) where
occName :: IEWrappedName (GhcPass p) -> OccName
occName IEWrappedName (GhcPass p)
w = forall name. HasOccName name => name -> OccName
occName (forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
w)
instance OutputableBndrId p => OutputableBndr (IEWrappedName (GhcPass p)) where
pprBndr :: BindingSite -> IEWrappedName (GhcPass p) -> SDoc
pprBndr BindingSite
bs IEWrappedName (GhcPass p)
w = forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
bs (forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
w)
pprPrefixOcc :: IEWrappedName (GhcPass p) -> SDoc
pprPrefixOcc IEWrappedName (GhcPass p)
w = forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
w)
pprInfixOcc :: IEWrappedName (GhcPass p) -> SDoc
pprInfixOcc IEWrappedName (GhcPass p)
w = forall a. OutputableBndr a => a -> SDoc
pprInfixOcc (forall (p :: Pass). IEWrappedName (GhcPass p) -> IdP (GhcPass p)
ieWrappedName IEWrappedName (GhcPass p)
w)
instance OutputableBndrId p => Outputable (IEWrappedName (GhcPass p)) where
ppr :: IEWrappedName (GhcPass p) -> SDoc
ppr (IEName XIEName (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
n)) = forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
n
ppr (IEPattern XIEPattern (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
n)) = forall doc. IsLine doc => String -> doc
text String
"pattern" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
n
ppr (IEType XIEType (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
n)) = forall doc. IsLine doc => String -> doc
text String
"type" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
n
pprImpExp :: (HasOccName name, OutputableBndr name) => name -> SDoc
pprImpExp :: forall name. (HasOccName name, OutputableBndr name) => name -> SDoc
pprImpExp name
name = SDoc
type_pref forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc name
name
where
occ :: OccName
occ = forall name. HasOccName name => name -> OccName
occName name
name
type_pref :: SDoc
type_pref | OccName -> Bool
isTcOcc OccName
occ Bool -> Bool -> Bool
&& OccName -> Bool
isSymOcc OccName
occ = forall doc. IsLine doc => String -> doc
text String
"type"
| Bool
otherwise = forall doc. IsOutput doc => doc
empty