{-# OPTIONS_GHC -O0 #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
module GHC.Hs (
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.Types,
module GHC.Hs.Utils,
module GHC.Hs.Doc,
module GHC.Hs.PlaceHolder,
module GHC.Hs.Extension,
Fixity,
HsModule(..),
) where
import GhcPrelude
import GHC.Hs.Decls
import GHC.Hs.Binds
import GHC.Hs.Expr
import GHC.Hs.ImpExp
import GHC.Hs.Lit
import GHC.Hs.PlaceHolder
import GHC.Hs.Extension
import GHC.Hs.Pat
import GHC.Hs.Types
import BasicTypes ( Fixity, WarningTxt )
import GHC.Hs.Utils
import GHC.Hs.Doc
import GHC.Hs.Instances ()
import Outputable
import SrcLoc
import Module ( ModuleName )
import Data.Data hiding ( Fixity )
data HsModule pass
= HsModule {
hsmodName :: Maybe (Located ModuleName),
hsmodExports :: Maybe (Located [LIE pass]),
hsmodImports :: [LImportDecl pass],
hsmodDecls :: [LHsDecl pass],
hsmodDeprecMessage :: Maybe (Located WarningTxt),
hsmodHaddockModHeader :: Maybe LHsDocString
}
deriving instance Data (HsModule GhcPs)
deriving instance Data (HsModule GhcRn)
deriving instance Data (HsModule GhcTc)
instance (OutputableBndrId p) => Outputable (HsModule (GhcPass p)) where
ppr (HsModule Nothing _ imports decls _ mbDoc)
= pp_mb mbDoc $$ pp_nonnull imports
$$ pp_nonnull decls
ppr (HsModule (Just name) exports imports decls deprec mbDoc)
= vcat [
pp_mb mbDoc,
case exports of
Nothing -> pp_header (text "where")
Just es -> vcat [
pp_header lparen,
nest 8 (fsep (punctuate comma (map ppr (unLoc es)))),
nest 4 (text ") where")
],
pp_nonnull imports,
pp_nonnull decls
]
where
pp_header rest = case deprec of
Nothing -> pp_modname <+> rest
Just d -> vcat [ pp_modname, ppr d, rest ]
pp_modname = text "module" <+> ppr name
pp_mb :: Outputable t => Maybe t -> SDoc
pp_mb (Just x) = ppr x
pp_mb Nothing = empty
pp_nonnull :: Outputable t => [t] -> SDoc
pp_nonnull [] = empty
pp_nonnull xs = vcat (map ppr xs)