{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

\section{Haskell abstract syntax definition}

This module glues together the pieces of the Haskell abstract syntax,
which is declared in the various \tr{Hs*} modules.  This module,
therefore, is almost nothing but re-exporting.
-}

{-# OPTIONS_GHC -Wno-orphans    #-} -- Outputable
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-} -- Wrinkle in Note [Trees That Grow]
                                      -- in module Language.Haskell.Syntax.Extension
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-} -- For deriving instance Data
{-# LANGUAGE DataKinds #-}

module GHC.Hs (
        module Language.Haskell.Syntax,
        module GHC.Hs.Binds,
        module GHC.Hs.Decls,
        module GHC.Hs.Expr,
        module GHC.Hs.ImpExp,
        module GHC.Hs.Lit,
        module GHC.Hs.Pat,
        module GHC.Hs.Type,
        module GHC.Hs.Utils,
        module GHC.Hs.Doc,
        module GHC.Hs.Extension,
        module GHC.Parser.Annotation,
        Fixity,

        HsModule(..), AnnsModule(..),
        HsParsedModule(..), XModulePs(..)
) where

-- friends:
import GHC.Prelude

import GHC.Hs.Decls
import GHC.Hs.Binds
import GHC.Hs.Expr
import GHC.Hs.ImpExp
import GHC.Hs.Lit
import Language.Haskell.Syntax
import GHC.Hs.Extension
import GHC.Parser.Annotation
import GHC.Hs.Pat
import GHC.Hs.Type
import GHC.Hs.Utils
import GHC.Hs.Doc
import GHC.Hs.Instances () -- For Data instances

-- others:
import GHC.Utils.Outputable
import GHC.Types.Fixity         ( Fixity )
import GHC.Types.SrcLoc
import GHC.Unit.Module.Warnings

-- libraries:
import Data.Data hiding ( Fixity )

-- | Haskell Module extension point: GHC specific
data XModulePs
  = XModulePs {
      XModulePs -> EpAnn AnnsModule
hsmodAnn :: EpAnn AnnsModule,
      XModulePs -> EpLayout
hsmodLayout :: EpLayout,
        -- ^ Layout info for the module.
        -- For incomplete modules (e.g. the output of parseHeader), it is EpNoLayout.
      XModulePs -> Maybe (LWarningTxt GhcPs)
hsmodDeprecMessage :: Maybe (LWarningTxt GhcPs),
        -- ^ reason\/explanation for warning/deprecation of this module
        --
        --  - 'GHC.Parser.Annotation.AnnKeywordId's : 'GHC.Parser.Annotation.AnnOpen'
        --                                   ,'GHC.Parser.Annotation.AnnClose'
        --

        -- For details on above see Note [exact print annotations] in GHC.Parser.Annotation
      XModulePs -> Maybe (LHsDoc GhcPs)
hsmodHaddockModHeader :: Maybe (LHsDoc GhcPs)
        -- ^ Haddock module info and description, unparsed
        --
        --  - 'GHC.Parser.Annotation.AnnKeywordId's : 'GHC.Parser.Annotation.AnnOpen'
        --                                   ,'GHC.Parser.Annotation.AnnClose'

        -- For details on above see Note [exact print annotations] in GHC.Parser.Annotation
   }
   deriving Typeable XModulePs
Typeable XModulePs =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> XModulePs -> c XModulePs)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c XModulePs)
-> (XModulePs -> Constr)
-> (XModulePs -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c XModulePs))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XModulePs))
-> ((forall b. Data b => b -> b) -> XModulePs -> XModulePs)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> XModulePs -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> XModulePs -> r)
-> (forall u. (forall d. Data d => d -> u) -> XModulePs -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> XModulePs -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> XModulePs -> m XModulePs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XModulePs -> m XModulePs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> XModulePs -> m XModulePs)
-> Data XModulePs
XModulePs -> Constr
XModulePs -> DataType
(forall b. Data b => b -> b) -> XModulePs -> XModulePs
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) -> XModulePs -> u
forall u. (forall d. Data d => d -> u) -> XModulePs -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> XModulePs -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> XModulePs -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XModulePs
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> XModulePs -> c XModulePs
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XModulePs)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XModulePs)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> XModulePs -> c XModulePs
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> XModulePs -> c XModulePs
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XModulePs
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XModulePs
$ctoConstr :: XModulePs -> Constr
toConstr :: XModulePs -> Constr
$cdataTypeOf :: XModulePs -> DataType
dataTypeOf :: XModulePs -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XModulePs)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XModulePs)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XModulePs)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c XModulePs)
$cgmapT :: (forall b. Data b => b -> b) -> XModulePs -> XModulePs
gmapT :: (forall b. Data b => b -> b) -> XModulePs -> XModulePs
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> XModulePs -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> XModulePs -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> XModulePs -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> XModulePs -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> XModulePs -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> XModulePs -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> XModulePs -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> XModulePs -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> XModulePs -> m XModulePs
Data

type instance XCModule GhcPs = XModulePs
type instance XCModule GhcRn = DataConCantHappen
type instance XCModule GhcTc = DataConCantHappen
type instance XXModule p = DataConCantHappen

deriving instance Data (HsModule GhcPs)

data AnnsModule
  = AnnsModule {
    AnnsModule -> EpToken "signature"
am_sig :: EpToken "signature",
    AnnsModule -> EpToken "module"
am_mod :: EpToken "module",
    AnnsModule -> EpToken "where"
am_where :: EpToken "where",
    AnnsModule -> [TrailingAnn]
am_decls :: [TrailingAnn],                 -- ^ Semis before the start of top decls
    AnnsModule -> [LEpaComment]
am_cs :: [LEpaComment],                    -- ^ Comments before start of top decl,
                                               --   used in exact printing only
    AnnsModule -> Maybe (RealSrcSpan, RealSrcSpan)
am_eof :: Maybe (RealSrcSpan, RealSrcSpan) -- ^ End of file and end of prior token
    } deriving (Typeable AnnsModule
Typeable AnnsModule =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnsModule -> c AnnsModule)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnsModule)
-> (AnnsModule -> Constr)
-> (AnnsModule -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnsModule))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnsModule))
-> ((forall b. Data b => b -> b) -> AnnsModule -> AnnsModule)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnsModule -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnsModule -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnsModule -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnsModule -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule)
-> Data AnnsModule
AnnsModule -> Constr
AnnsModule -> DataType
(forall b. Data b => b -> b) -> AnnsModule -> AnnsModule
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) -> AnnsModule -> u
forall u. (forall d. Data d => d -> u) -> AnnsModule -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnsModule -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnsModule -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnsModule
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnsModule -> c AnnsModule
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnsModule)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnsModule)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnsModule -> c AnnsModule
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnsModule -> c AnnsModule
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnsModule
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnsModule
$ctoConstr :: AnnsModule -> Constr
toConstr :: AnnsModule -> Constr
$cdataTypeOf :: AnnsModule -> DataType
dataTypeOf :: AnnsModule -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnsModule)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnsModule)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnsModule)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnsModule)
$cgmapT :: (forall b. Data b => b -> b) -> AnnsModule -> AnnsModule
gmapT :: (forall b. Data b => b -> b) -> AnnsModule -> AnnsModule
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnsModule -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnsModule -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnsModule -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnsModule -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnsModule -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnsModule -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnsModule -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnsModule -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnsModule -> m AnnsModule
Data, AnnsModule -> AnnsModule -> Bool
(AnnsModule -> AnnsModule -> Bool)
-> (AnnsModule -> AnnsModule -> Bool) -> Eq AnnsModule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AnnsModule -> AnnsModule -> Bool
== :: AnnsModule -> AnnsModule -> Bool
$c/= :: AnnsModule -> AnnsModule -> Bool
/= :: AnnsModule -> AnnsModule -> Bool
Eq)

instance NoAnn AnnsModule where
  noAnn :: AnnsModule
noAnn = EpToken "signature"
-> EpToken "module"
-> EpToken "where"
-> [TrailingAnn]
-> [LEpaComment]
-> Maybe (RealSrcSpan, RealSrcSpan)
-> AnnsModule
AnnsModule EpToken "signature"
forall (tok :: Symbol). EpToken tok
NoEpTok EpToken "module"
forall (tok :: Symbol). EpToken tok
NoEpTok EpToken "where"
forall (tok :: Symbol). EpToken tok
NoEpTok [] [] Maybe (RealSrcSpan, RealSrcSpan)
forall a. Maybe a
Nothing

instance Outputable (HsModule GhcPs) where
    ppr :: HsModule GhcPs -> SDoc
ppr (HsModule { hsmodExt :: forall p. HsModule p -> XCModule p
hsmodExt = XModulePs { hsmodHaddockModHeader :: XModulePs -> Maybe (LHsDoc GhcPs)
hsmodHaddockModHeader = Maybe (LHsDoc GhcPs)
mbDoc }
                  , hsmodName :: forall p. HsModule p -> Maybe (XRec p ModuleName)
hsmodName = Maybe (XRec GhcPs ModuleName)
Nothing
                  , hsmodImports :: forall p. HsModule p -> [LImportDecl p]
hsmodImports = [LImportDecl GhcPs]
imports
                  , hsmodDecls :: forall p. HsModule p -> [LHsDecl p]
hsmodDecls = [LHsDecl GhcPs]
decls })
      = Maybe (LHsDoc GhcPs) -> SDoc -> SDoc
forall name. Maybe (LHsDoc name) -> SDoc -> SDoc
pprMaybeWithDoc Maybe (LHsDoc GhcPs)
mbDoc (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [GenLocated SrcSpanAnnA (ImportDecl GhcPs)] -> SDoc
forall t. Outputable t => [t] -> SDoc
pp_nonnull [LImportDecl GhcPs]
[GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
imports
                             SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ [GenLocated SrcSpanAnnA (HsDecl GhcPs)] -> SDoc
forall t. Outputable t => [t] -> SDoc
pp_nonnull [LHsDecl GhcPs]
[GenLocated SrcSpanAnnA (HsDecl GhcPs)]
decls

    ppr (HsModule { hsmodExt :: forall p. HsModule p -> XCModule p
hsmodExt = XModulePs { hsmodDeprecMessage :: XModulePs -> Maybe (LWarningTxt GhcPs)
hsmodDeprecMessage = Maybe (LWarningTxt GhcPs)
deprec
                                         , hsmodHaddockModHeader :: XModulePs -> Maybe (LHsDoc GhcPs)
hsmodHaddockModHeader = Maybe (LHsDoc GhcPs)
mbDoc }
                  , hsmodName :: forall p. HsModule p -> Maybe (XRec p ModuleName)
hsmodName = (Just XRec GhcPs ModuleName
name)
                  , hsmodExports :: forall p. HsModule p -> Maybe (XRec p [LIE p])
hsmodExports = Maybe (XRec GhcPs [LIE GhcPs])
exports
                  , hsmodImports :: forall p. HsModule p -> [LImportDecl p]
hsmodImports = [LImportDecl GhcPs]
imports
                  , hsmodDecls :: forall p. HsModule p -> [LHsDecl p]
hsmodDecls = [LHsDecl GhcPs]
decls })
      = Maybe (LHsDoc GhcPs) -> SDoc -> SDoc
forall name. Maybe (LHsDoc name) -> SDoc -> SDoc
pprMaybeWithDoc Maybe (LHsDoc GhcPs)
mbDoc (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
        [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat
          [ case Maybe (XRec GhcPs [LIE GhcPs])
exports of
              Maybe (XRec GhcPs [LIE GhcPs])
Nothing -> SDoc -> SDoc
pp_header (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where")
              Just XRec GhcPs [LIE GhcPs]
es -> [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [
                           SDoc -> SDoc
pp_header SDoc
forall doc. IsLine doc => doc
lparen,
                           Int -> SDoc -> SDoc
nest Int
8 ((GenLocated SrcSpanAnnA (IE GhcPs) -> SDoc)
-> [GenLocated SrcSpanAnnA (IE GhcPs)] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas GenLocated SrcSpanAnnA (IE GhcPs) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
-> [GenLocated SrcSpanAnnA (IE GhcPs)]
forall l e. GenLocated l e -> e
unLoc XRec GhcPs [LIE GhcPs]
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
es)),
                           Int -> SDoc -> SDoc
nest Int
4 (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
") where")
                          ],
            [GenLocated SrcSpanAnnA (ImportDecl GhcPs)] -> SDoc
forall t. Outputable t => [t] -> SDoc
pp_nonnull [LImportDecl GhcPs]
[GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
imports,
            [GenLocated SrcSpanAnnA (HsDecl GhcPs)] -> SDoc
forall t. Outputable t => [t] -> SDoc
pp_nonnull [LHsDecl GhcPs]
[GenLocated SrcSpanAnnA (HsDecl GhcPs)]
decls
          ]
      where
        pp_header :: SDoc -> SDoc
pp_header SDoc
rest = case Maybe (LWarningTxt GhcPs)
deprec of
           Maybe (LWarningTxt GhcPs)
Nothing -> SDoc
pp_modname SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
rest
           Just LWarningTxt GhcPs
d -> [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
pp_modname, GenLocated SrcSpanAnnP (WarningTxt GhcPs) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LWarningTxt GhcPs
GenLocated SrcSpanAnnP (WarningTxt GhcPs)
d, SDoc
rest ]

        pp_modname :: SDoc
pp_modname = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"module" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec GhcPs ModuleName
GenLocated SrcSpanAnnA ModuleName
name

pp_nonnull :: Outputable t => [t] -> SDoc
pp_nonnull :: forall t. Outputable t => [t] -> SDoc
pp_nonnull [] = SDoc
forall doc. IsOutput doc => doc
empty
pp_nonnull [t]
xs = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((t -> SDoc) -> [t] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map t -> SDoc
forall a. Outputable a => a -> SDoc
ppr [t]
xs)

data HsParsedModule = HsParsedModule {
    HsParsedModule -> Located (HsModule GhcPs)
hpm_module    :: Located (HsModule GhcPs),
    HsParsedModule -> [String]
hpm_src_files :: [FilePath]
       -- ^ extra source files (e.g. from #includes).  The lexer collects
       -- these from '# <file> <line>' pragmas, which the C preprocessor
       -- leaves behind.  These files and their timestamps are stored in
       -- the .hi file, so that we can force recompilation if any of
       -- them change (#3589)
  }