{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module GHC.Hs.Decls (
HsDecl(..), LHsDecl, HsDataDefn(..), HsDeriving, LHsFunDep,
HsDerivingClause(..), LHsDerivingClause, DerivClauseTys(..), LDerivClauseTys,
NewOrData, newOrDataToFlavour, anyLConIsGadt,
StandaloneKindSig(..), LStandaloneKindSig, standaloneKindSigName,
TyClDecl(..), LTyClDecl, DataDeclRn(..),
TyClGroup(..),
tyClGroupTyClDecls, tyClGroupInstDecls, tyClGroupRoleDecls,
tyClGroupKindSigs,
isClassDecl, isDataDecl, isSynDecl, tcdName,
isFamilyDecl, isTypeFamilyDecl, isDataFamilyDecl,
isOpenTypeFamilyInfo, isClosedTypeFamilyInfo,
tyFamInstDeclName, tyFamInstDeclLName,
countTyClDecls, pprTyClDeclFlavour,
tyClDeclLName, tyClDeclTyVars,
hsDeclHasCusk, famResultKindSignature,
FamilyDecl(..), LFamilyDecl,
FunDep(..), ppDataDefnHeader,
pp_vanilla_decl_head,
InstDecl(..), LInstDecl, FamilyInfo(..),
TyFamInstDecl(..), LTyFamInstDecl, instDeclDataFamInsts,
TyFamDefltDecl, LTyFamDefltDecl,
DataFamInstDecl(..), LDataFamInstDecl,
pprDataFamInstFlavour, pprTyFamInstDecl, pprHsFamInstLHS,
FamEqn(..), TyFamInstEqn, LTyFamInstEqn, HsTyPats,
LClsInstDecl, ClsInstDecl(..),
DerivDecl(..), LDerivDecl,
DerivStrategy(..), LDerivStrategy,
derivStrategyName, foldDerivStrategy, mapDerivStrategy,
XViaStrategyPs(..),
LRuleDecls,RuleDecls(..),RuleDecl(..),LRuleDecl,HsRuleRn(..),
HsRuleAnn(..),
RuleBndr(..),LRuleBndr,
collectRuleBndrSigTys,
flattenRuleDecls, pprFullRuleName,
DefaultDecl(..), LDefaultDecl,
SpliceDecoration(..),
SpliceDecl(..), LSpliceDecl,
ForeignDecl(..), LForeignDecl, ForeignImport(..), ForeignExport(..),
CImportSpec(..),
ConDecl(..), LConDecl,
HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta,
getConNames, getRecConArgs_maybe,
DocDecl(..), LDocDecl, docDeclDoc,
WarnDecl(..), LWarnDecl,
WarnDecls(..), LWarnDecls,
AnnDecl(..), LAnnDecl,
AnnProvenance(..), annProvenanceName_maybe,
RoleAnnotDecl(..), LRoleAnnotDecl, roleAnnotDeclName,
FamilyResultSig(..), LFamilyResultSig, InjectivityAnn(..), LInjectivityAnn,
resultVariableName, familyDeclLName, familyDeclName,
HsGroup(..), emptyRdrGroup, emptyRnGroup, appendGroups, hsGroupInstDecls,
hsGroupTopLevelFixitySigs,
partitionBindsAndSigs,
) where
import GHC.Prelude
import Language.Haskell.Syntax.Decls
import {-# SOURCE #-} GHC.Hs.Expr ( pprExpr, pprUntypedSplice )
import GHC.Hs.Binds
import GHC.Hs.Type
import GHC.Hs.Doc
import GHC.Types.Basic
import GHC.Core.Coercion
import Language.Haskell.Syntax.Extension
import GHC.Hs.Extension
import GHC.Parser.Annotation
import GHC.Types.Name
import GHC.Types.Name.Set
import GHC.Types.Fixity
import GHC.Utils.Misc (count)
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Types.SrcLoc
import GHC.Types.SourceText
import GHC.Core.Type
import GHC.Core.TyCon (TyConFlavour(NewtypeFlavour,DataTypeFlavour))
import GHC.Types.ForeignCall
import GHC.Data.Bag
import GHC.Data.Maybe
import Data.Data (Data)
import Data.Foldable (toList)
type instance XTyClD (GhcPass _) = NoExtField
type instance XInstD (GhcPass _) = NoExtField
type instance XDerivD (GhcPass _) = NoExtField
type instance XValD (GhcPass _) = NoExtField
type instance XSigD (GhcPass _) = NoExtField
type instance XKindSigD (GhcPass _) = NoExtField
type instance XDefD (GhcPass _) = NoExtField
type instance XForD (GhcPass _) = NoExtField
type instance XWarningD (GhcPass _) = NoExtField
type instance XAnnD (GhcPass _) = NoExtField
type instance XRuleD (GhcPass _) = NoExtField
type instance XSpliceD (GhcPass _) = NoExtField
type instance XDocD (GhcPass _) = NoExtField
type instance XRoleAnnotD (GhcPass _) = NoExtField
type instance XXHsDecl (GhcPass _) = DataConCantHappen
partitionBindsAndSigs
:: [LHsDecl GhcPs]
-> (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs],
[LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs])
partitionBindsAndSigs :: [LHsDecl GhcPs]
-> (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs],
[LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs])
partitionBindsAndSigs = forall {p} {l}.
Outputable (HsDecl p) =>
[GenLocated l (HsDecl p)]
-> (Bag (GenLocated l (HsBind p)), [GenLocated l (Sig p)],
[GenLocated l (FamilyDecl p)], [GenLocated l (TyFamInstDecl p)],
[GenLocated l (DataFamInstDecl p)], [GenLocated l (DocDecl p)])
go
where
go :: [GenLocated l (HsDecl p)]
-> (Bag (GenLocated l (HsBind p)), [GenLocated l (Sig p)],
[GenLocated l (FamilyDecl p)], [GenLocated l (TyFamInstDecl p)],
[GenLocated l (DataFamInstDecl p)], [GenLocated l (DocDecl p)])
go [] = (forall a. Bag a
emptyBag, [], [], [], [], [])
go ((L l
l HsDecl p
decl) : [GenLocated l (HsDecl p)]
ds) =
let (Bag (GenLocated l (HsBind p))
bs, [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, [GenLocated l (TyFamInstDecl p)]
tfis, [GenLocated l (DataFamInstDecl p)]
dfis, [GenLocated l (DocDecl p)]
docs) = [GenLocated l (HsDecl p)]
-> (Bag (GenLocated l (HsBind p)), [GenLocated l (Sig p)],
[GenLocated l (FamilyDecl p)], [GenLocated l (TyFamInstDecl p)],
[GenLocated l (DataFamInstDecl p)], [GenLocated l (DocDecl p)])
go [GenLocated l (HsDecl p)]
ds in
case HsDecl p
decl of
ValD XValD p
_ HsBind p
b
-> (forall l e. l -> e -> GenLocated l e
L l
l HsBind p
b forall a. a -> Bag a -> Bag a
`consBag` Bag (GenLocated l (HsBind p))
bs, [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, [GenLocated l (TyFamInstDecl p)]
tfis, [GenLocated l (DataFamInstDecl p)]
dfis, [GenLocated l (DocDecl p)]
docs)
SigD XSigD p
_ Sig p
s
-> (Bag (GenLocated l (HsBind p))
bs, forall l e. l -> e -> GenLocated l e
L l
l Sig p
s forall a. a -> [a] -> [a]
: [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, [GenLocated l (TyFamInstDecl p)]
tfis, [GenLocated l (DataFamInstDecl p)]
dfis, [GenLocated l (DocDecl p)]
docs)
TyClD XTyClD p
_ (FamDecl XFamDecl p
_ FamilyDecl p
t)
-> (Bag (GenLocated l (HsBind p))
bs, [GenLocated l (Sig p)]
ss, forall l e. l -> e -> GenLocated l e
L l
l FamilyDecl p
t forall a. a -> [a] -> [a]
: [GenLocated l (FamilyDecl p)]
ts, [GenLocated l (TyFamInstDecl p)]
tfis, [GenLocated l (DataFamInstDecl p)]
dfis, [GenLocated l (DocDecl p)]
docs)
InstD XInstD p
_ (TyFamInstD { tfid_inst :: forall pass. InstDecl pass -> TyFamInstDecl pass
tfid_inst = TyFamInstDecl p
tfi })
-> (Bag (GenLocated l (HsBind p))
bs, [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, forall l e. l -> e -> GenLocated l e
L l
l TyFamInstDecl p
tfi forall a. a -> [a] -> [a]
: [GenLocated l (TyFamInstDecl p)]
tfis, [GenLocated l (DataFamInstDecl p)]
dfis, [GenLocated l (DocDecl p)]
docs)
InstD XInstD p
_ (DataFamInstD { dfid_inst :: forall pass. InstDecl pass -> DataFamInstDecl pass
dfid_inst = DataFamInstDecl p
dfi })
-> (Bag (GenLocated l (HsBind p))
bs, [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, [GenLocated l (TyFamInstDecl p)]
tfis, forall l e. l -> e -> GenLocated l e
L l
l DataFamInstDecl p
dfi forall a. a -> [a] -> [a]
: [GenLocated l (DataFamInstDecl p)]
dfis, [GenLocated l (DocDecl p)]
docs)
DocD XDocD p
_ DocDecl p
d
-> (Bag (GenLocated l (HsBind p))
bs, [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, [GenLocated l (TyFamInstDecl p)]
tfis, [GenLocated l (DataFamInstDecl p)]
dfis, forall l e. l -> e -> GenLocated l e
L l
l DocDecl p
d forall a. a -> [a] -> [a]
: [GenLocated l (DocDecl p)]
docs)
HsDecl p
_ -> forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"partitionBindsAndSigs" (forall a. Outputable a => a -> SDoc
ppr HsDecl p
decl)
instance Outputable (DocDecl name) where
ppr :: DocDecl name -> SDoc
ppr DocDecl name
_ = forall doc. IsLine doc => String -> doc
text String
"<document comment>"
type instance XCHsGroup (GhcPass _) = NoExtField
type instance XXHsGroup (GhcPass _) = DataConCantHappen
emptyGroup, emptyRdrGroup, emptyRnGroup :: HsGroup (GhcPass p)
emptyRdrGroup :: forall (p :: Pass). HsGroup (GhcPass p)
emptyRdrGroup = forall (p :: Pass). HsGroup (GhcPass p)
emptyGroup { hs_valds :: HsValBinds (GhcPass p)
hs_valds = forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b)
emptyValBindsIn }
emptyRnGroup :: forall (p :: Pass). HsGroup (GhcPass p)
emptyRnGroup = forall (p :: Pass). HsGroup (GhcPass p)
emptyGroup { hs_valds :: HsValBinds (GhcPass p)
hs_valds = forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b)
emptyValBindsOut }
emptyGroup :: forall (p :: Pass). HsGroup (GhcPass p)
emptyGroup = HsGroup { hs_ext :: XCHsGroup (GhcPass p)
hs_ext = NoExtField
noExtField,
hs_tyclds :: [TyClGroup (GhcPass p)]
hs_tyclds = [],
hs_derivds :: [LDerivDecl (GhcPass p)]
hs_derivds = [],
hs_fixds :: [LFixitySig (GhcPass p)]
hs_fixds = [], hs_defds :: [LDefaultDecl (GhcPass p)]
hs_defds = [], hs_annds :: [LAnnDecl (GhcPass p)]
hs_annds = [],
hs_fords :: [LForeignDecl (GhcPass p)]
hs_fords = [], hs_warnds :: [LWarnDecls (GhcPass p)]
hs_warnds = [], hs_ruleds :: [LRuleDecls (GhcPass p)]
hs_ruleds = [],
hs_valds :: HsValBinds (GhcPass p)
hs_valds = forall a. HasCallStack => String -> a
error String
"emptyGroup hs_valds: Can't happen",
hs_splcds :: [LSpliceDecl (GhcPass p)]
hs_splcds = [],
hs_docs :: [LDocDecl (GhcPass p)]
hs_docs = [] }
hsGroupTopLevelFixitySigs :: HsGroup (GhcPass p) -> [LFixitySig (GhcPass p)]
hsGroupTopLevelFixitySigs :: forall (p :: Pass). HsGroup (GhcPass p) -> [LFixitySig (GhcPass p)]
hsGroupTopLevelFixitySigs (HsGroup{ hs_fixds :: forall p. HsGroup p -> [LFixitySig p]
hs_fixds = [LFixitySig (GhcPass p)]
fixds, hs_tyclds :: forall p. HsGroup p -> [TyClGroup p]
hs_tyclds = [TyClGroup (GhcPass p)]
tyclds }) =
[LFixitySig (GhcPass p)]
fixds forall a. [a] -> [a] -> [a]
++ [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
cls_fixds
where
cls_fixds :: [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
cls_fixds = [ forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
loc FixitySig (GhcPass p)
sig
| L SrcSpanAnnA
_ ClassDecl{tcdSigs :: forall pass. TyClDecl pass -> [LSig pass]
tcdSigs = [LSig (GhcPass p)]
sigs} <- forall pass. [TyClGroup pass] -> [LTyClDecl pass]
tyClGroupTyClDecls [TyClGroup (GhcPass p)]
tyclds
, L SrcSpanAnnA
loc (FixSig XFixSig (GhcPass p)
_ FixitySig (GhcPass p)
sig) <- [LSig (GhcPass p)]
sigs
]
appendGroups :: HsGroup (GhcPass p) -> HsGroup (GhcPass p)
-> HsGroup (GhcPass p)
appendGroups :: forall (p :: Pass).
HsGroup (GhcPass p) -> HsGroup (GhcPass p) -> HsGroup (GhcPass p)
appendGroups
HsGroup {
hs_valds :: forall p. HsGroup p -> HsValBinds p
hs_valds = HsValBinds (GhcPass p)
val_groups1,
hs_splcds :: forall p. HsGroup p -> [LSpliceDecl p]
hs_splcds = [LSpliceDecl (GhcPass p)]
spliceds1,
hs_tyclds :: forall p. HsGroup p -> [TyClGroup p]
hs_tyclds = [TyClGroup (GhcPass p)]
tyclds1,
hs_derivds :: forall p. HsGroup p -> [LDerivDecl p]
hs_derivds = [LDerivDecl (GhcPass p)]
derivds1,
hs_fixds :: forall p. HsGroup p -> [LFixitySig p]
hs_fixds = [LFixitySig (GhcPass p)]
fixds1,
hs_defds :: forall p. HsGroup p -> [LDefaultDecl p]
hs_defds = [LDefaultDecl (GhcPass p)]
defds1,
hs_annds :: forall p. HsGroup p -> [LAnnDecl p]
hs_annds = [LAnnDecl (GhcPass p)]
annds1,
hs_fords :: forall p. HsGroup p -> [LForeignDecl p]
hs_fords = [LForeignDecl (GhcPass p)]
fords1,
hs_warnds :: forall p. HsGroup p -> [LWarnDecls p]
hs_warnds = [LWarnDecls (GhcPass p)]
warnds1,
hs_ruleds :: forall p. HsGroup p -> [LRuleDecls p]
hs_ruleds = [LRuleDecls (GhcPass p)]
rulds1,
hs_docs :: forall p. HsGroup p -> [LDocDecl p]
hs_docs = [LDocDecl (GhcPass p)]
docs1 }
HsGroup {
hs_valds :: forall p. HsGroup p -> HsValBinds p
hs_valds = HsValBinds (GhcPass p)
val_groups2,
hs_splcds :: forall p. HsGroup p -> [LSpliceDecl p]
hs_splcds = [LSpliceDecl (GhcPass p)]
spliceds2,
hs_tyclds :: forall p. HsGroup p -> [TyClGroup p]
hs_tyclds = [TyClGroup (GhcPass p)]
tyclds2,
hs_derivds :: forall p. HsGroup p -> [LDerivDecl p]
hs_derivds = [LDerivDecl (GhcPass p)]
derivds2,
hs_fixds :: forall p. HsGroup p -> [LFixitySig p]
hs_fixds = [LFixitySig (GhcPass p)]
fixds2,
hs_defds :: forall p. HsGroup p -> [LDefaultDecl p]
hs_defds = [LDefaultDecl (GhcPass p)]
defds2,
hs_annds :: forall p. HsGroup p -> [LAnnDecl p]
hs_annds = [LAnnDecl (GhcPass p)]
annds2,
hs_fords :: forall p. HsGroup p -> [LForeignDecl p]
hs_fords = [LForeignDecl (GhcPass p)]
fords2,
hs_warnds :: forall p. HsGroup p -> [LWarnDecls p]
hs_warnds = [LWarnDecls (GhcPass p)]
warnds2,
hs_ruleds :: forall p. HsGroup p -> [LRuleDecls p]
hs_ruleds = [LRuleDecls (GhcPass p)]
rulds2,
hs_docs :: forall p. HsGroup p -> [LDocDecl p]
hs_docs = [LDocDecl (GhcPass p)]
docs2 }
=
HsGroup {
hs_ext :: XCHsGroup (GhcPass p)
hs_ext = NoExtField
noExtField,
hs_valds :: HsValBinds (GhcPass p)
hs_valds = HsValBinds (GhcPass p)
val_groups1 forall (a :: Pass).
HsValBinds (GhcPass a)
-> HsValBinds (GhcPass a) -> HsValBinds (GhcPass a)
`plusHsValBinds` HsValBinds (GhcPass p)
val_groups2,
hs_splcds :: [LSpliceDecl (GhcPass p)]
hs_splcds = [LSpliceDecl (GhcPass p)]
spliceds1 forall a. [a] -> [a] -> [a]
++ [LSpliceDecl (GhcPass p)]
spliceds2,
hs_tyclds :: [TyClGroup (GhcPass p)]
hs_tyclds = [TyClGroup (GhcPass p)]
tyclds1 forall a. [a] -> [a] -> [a]
++ [TyClGroup (GhcPass p)]
tyclds2,
hs_derivds :: [LDerivDecl (GhcPass p)]
hs_derivds = [LDerivDecl (GhcPass p)]
derivds1 forall a. [a] -> [a] -> [a]
++ [LDerivDecl (GhcPass p)]
derivds2,
hs_fixds :: [LFixitySig (GhcPass p)]
hs_fixds = [LFixitySig (GhcPass p)]
fixds1 forall a. [a] -> [a] -> [a]
++ [LFixitySig (GhcPass p)]
fixds2,
hs_annds :: [LAnnDecl (GhcPass p)]
hs_annds = [LAnnDecl (GhcPass p)]
annds1 forall a. [a] -> [a] -> [a]
++ [LAnnDecl (GhcPass p)]
annds2,
hs_defds :: [LDefaultDecl (GhcPass p)]
hs_defds = [LDefaultDecl (GhcPass p)]
defds1 forall a. [a] -> [a] -> [a]
++ [LDefaultDecl (GhcPass p)]
defds2,
hs_fords :: [LForeignDecl (GhcPass p)]
hs_fords = [LForeignDecl (GhcPass p)]
fords1 forall a. [a] -> [a] -> [a]
++ [LForeignDecl (GhcPass p)]
fords2,
hs_warnds :: [LWarnDecls (GhcPass p)]
hs_warnds = [LWarnDecls (GhcPass p)]
warnds1 forall a. [a] -> [a] -> [a]
++ [LWarnDecls (GhcPass p)]
warnds2,
hs_ruleds :: [LRuleDecls (GhcPass p)]
hs_ruleds = [LRuleDecls (GhcPass p)]
rulds1 forall a. [a] -> [a] -> [a]
++ [LRuleDecls (GhcPass p)]
rulds2,
hs_docs :: [LDocDecl (GhcPass p)]
hs_docs = [LDocDecl (GhcPass p)]
docs1 forall a. [a] -> [a] -> [a]
++ [LDocDecl (GhcPass p)]
docs2 }
instance (OutputableBndrId p) => Outputable (HsDecl (GhcPass p)) where
ppr :: HsDecl (GhcPass p) -> SDoc
ppr (TyClD XTyClD (GhcPass p)
_ TyClDecl (GhcPass p)
dcl) = forall a. Outputable a => a -> SDoc
ppr TyClDecl (GhcPass p)
dcl
ppr (ValD XValD (GhcPass p)
_ HsBind (GhcPass p)
binds) = forall a. Outputable a => a -> SDoc
ppr HsBind (GhcPass p)
binds
ppr (DefD XDefD (GhcPass p)
_ DefaultDecl (GhcPass p)
def) = forall a. Outputable a => a -> SDoc
ppr DefaultDecl (GhcPass p)
def
ppr (InstD XInstD (GhcPass p)
_ InstDecl (GhcPass p)
inst) = forall a. Outputable a => a -> SDoc
ppr InstDecl (GhcPass p)
inst
ppr (DerivD XDerivD (GhcPass p)
_ DerivDecl (GhcPass p)
deriv) = forall a. Outputable a => a -> SDoc
ppr DerivDecl (GhcPass p)
deriv
ppr (ForD XForD (GhcPass p)
_ ForeignDecl (GhcPass p)
fd) = forall a. Outputable a => a -> SDoc
ppr ForeignDecl (GhcPass p)
fd
ppr (SigD XSigD (GhcPass p)
_ Sig (GhcPass p)
sd) = forall a. Outputable a => a -> SDoc
ppr Sig (GhcPass p)
sd
ppr (KindSigD XKindSigD (GhcPass p)
_ StandaloneKindSig (GhcPass p)
ksd) = forall a. Outputable a => a -> SDoc
ppr StandaloneKindSig (GhcPass p)
ksd
ppr (RuleD XRuleD (GhcPass p)
_ RuleDecls (GhcPass p)
rd) = forall a. Outputable a => a -> SDoc
ppr RuleDecls (GhcPass p)
rd
ppr (WarningD XWarningD (GhcPass p)
_ WarnDecls (GhcPass p)
wd) = forall a. Outputable a => a -> SDoc
ppr WarnDecls (GhcPass p)
wd
ppr (AnnD XAnnD (GhcPass p)
_ AnnDecl (GhcPass p)
ad) = forall a. Outputable a => a -> SDoc
ppr AnnDecl (GhcPass p)
ad
ppr (SpliceD XSpliceD (GhcPass p)
_ SpliceDecl (GhcPass p)
dd) = forall a. Outputable a => a -> SDoc
ppr SpliceDecl (GhcPass p)
dd
ppr (DocD XDocD (GhcPass p)
_ DocDecl (GhcPass p)
doc) = forall a. Outputable a => a -> SDoc
ppr DocDecl (GhcPass p)
doc
ppr (RoleAnnotD XRoleAnnotD (GhcPass p)
_ RoleAnnotDecl (GhcPass p)
ra) = forall a. Outputable a => a -> SDoc
ppr RoleAnnotDecl (GhcPass p)
ra
instance (OutputableBndrId p) => Outputable (HsGroup (GhcPass p)) where
ppr :: HsGroup (GhcPass p) -> SDoc
ppr (HsGroup { hs_valds :: forall p. HsGroup p -> HsValBinds p
hs_valds = HsValBinds (GhcPass p)
val_decls,
hs_tyclds :: forall p. HsGroup p -> [TyClGroup p]
hs_tyclds = [TyClGroup (GhcPass p)]
tycl_decls,
hs_derivds :: forall p. HsGroup p -> [LDerivDecl p]
hs_derivds = [LDerivDecl (GhcPass p)]
deriv_decls,
hs_fixds :: forall p. HsGroup p -> [LFixitySig p]
hs_fixds = [LFixitySig (GhcPass p)]
fix_decls,
hs_warnds :: forall p. HsGroup p -> [LWarnDecls p]
hs_warnds = [LWarnDecls (GhcPass p)]
deprec_decls,
hs_annds :: forall p. HsGroup p -> [LAnnDecl p]
hs_annds = [LAnnDecl (GhcPass p)]
ann_decls,
hs_fords :: forall p. HsGroup p -> [LForeignDecl p]
hs_fords = [LForeignDecl (GhcPass p)]
foreign_decls,
hs_defds :: forall p. HsGroup p -> [LDefaultDecl p]
hs_defds = [LDefaultDecl (GhcPass p)]
default_decls,
hs_ruleds :: forall p. HsGroup p -> [LRuleDecls p]
hs_ruleds = [LRuleDecls (GhcPass p)]
rule_decls })
= SDoc -> [Maybe SDoc] -> SDoc
vcat_mb forall doc. IsOutput doc => doc
empty
[forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LFixitySig (GhcPass p)]
fix_decls, forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LDefaultDecl (GhcPass p)]
default_decls,
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LWarnDecls (GhcPass p)]
deprec_decls, forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LAnnDecl (GhcPass p)]
ann_decls,
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LRuleDecls (GhcPass p)]
rule_decls,
if forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b) -> Bool
isEmptyValBinds HsValBinds (GhcPass p)
val_decls
then forall a. Maybe a
Nothing
else forall a. a -> Maybe a
Just (forall a. Outputable a => a -> SDoc
ppr HsValBinds (GhcPass p)
val_decls),
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds (forall pass. [TyClGroup pass] -> [LRoleAnnotDecl pass]
tyClGroupRoleDecls [TyClGroup (GhcPass p)]
tycl_decls),
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds (forall pass. [TyClGroup pass] -> [LStandaloneKindSig pass]
tyClGroupKindSigs [TyClGroup (GhcPass p)]
tycl_decls),
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds (forall pass. [TyClGroup pass] -> [LTyClDecl pass]
tyClGroupTyClDecls [TyClGroup (GhcPass p)]
tycl_decls),
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds (forall pass. [TyClGroup pass] -> [LInstDecl pass]
tyClGroupInstDecls [TyClGroup (GhcPass p)]
tycl_decls),
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LDerivDecl (GhcPass p)]
deriv_decls,
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LForeignDecl (GhcPass p)]
foreign_decls]
where
ppr_ds :: Outputable a => [a] -> Maybe SDoc
ppr_ds :: forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [] = forall a. Maybe a
Nothing
ppr_ds [a]
ds = forall a. a -> Maybe a
Just (forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [a]
ds))
vcat_mb :: SDoc -> [Maybe SDoc] -> SDoc
vcat_mb :: SDoc -> [Maybe SDoc] -> SDoc
vcat_mb SDoc
_ [] = forall doc. IsOutput doc => doc
empty
vcat_mb SDoc
gap (Maybe SDoc
Nothing : [Maybe SDoc]
ds) = SDoc -> [Maybe SDoc] -> SDoc
vcat_mb SDoc
gap [Maybe SDoc]
ds
vcat_mb SDoc
gap (Just SDoc
d : [Maybe SDoc]
ds) = SDoc
gap forall doc. IsDoc doc => doc -> doc -> doc
$$ SDoc
d forall doc. IsDoc doc => doc -> doc -> doc
$$ SDoc -> [Maybe SDoc] -> SDoc
vcat_mb SDoc
blankLine [Maybe SDoc]
ds
type instance XSpliceDecl (GhcPass _) = NoExtField
type instance XXSpliceDecl (GhcPass _) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (SpliceDecl (GhcPass p)) where
ppr :: SpliceDecl (GhcPass p) -> SDoc
ppr (SpliceDecl XSpliceDecl (GhcPass p)
_ (L Anno (HsUntypedSplice (GhcPass p))
_ HsUntypedSplice (GhcPass p)
e) SpliceDecoration
DollarSplice) = forall (p :: Pass).
OutputableBndrId p =>
Bool
-> Maybe SplicePointName -> HsUntypedSplice (GhcPass p) -> SDoc
pprUntypedSplice Bool
True forall a. Maybe a
Nothing HsUntypedSplice (GhcPass p)
e
ppr (SpliceDecl XSpliceDecl (GhcPass p)
_ (L Anno (HsUntypedSplice (GhcPass p))
_ HsUntypedSplice (GhcPass p)
e) SpliceDecoration
BareSplice) = forall (p :: Pass).
OutputableBndrId p =>
Bool
-> Maybe SplicePointName -> HsUntypedSplice (GhcPass p) -> SDoc
pprUntypedSplice Bool
False forall a. Maybe a
Nothing HsUntypedSplice (GhcPass p)
e
instance Outputable SpliceDecoration where
ppr :: SpliceDecoration -> SDoc
ppr SpliceDecoration
x = forall doc. IsLine doc => String -> doc
text forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show SpliceDecoration
x
type instance XFamDecl (GhcPass _) = NoExtField
type instance XSynDecl GhcPs = EpAnn [AddEpAnn]
type instance XSynDecl GhcRn = NameSet
type instance XSynDecl GhcTc = NameSet
type instance XDataDecl GhcPs = EpAnn [AddEpAnn]
type instance XDataDecl GhcRn = DataDeclRn
type instance XDataDecl GhcTc = DataDeclRn
data DataDeclRn = DataDeclRn
{ DataDeclRn -> Bool
tcdDataCusk :: Bool
, DataDeclRn -> NameSet
tcdFVs :: NameSet }
deriving Typeable DataDeclRn
DataDeclRn -> DataType
DataDeclRn -> Constr
(forall b. Data b => b -> b) -> DataDeclRn -> DataDeclRn
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) -> DataDeclRn -> u
forall u. (forall d. Data d => d -> u) -> DataDeclRn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclRn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclRn -> c DataDeclRn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclRn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDeclRn)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDeclRn -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDeclRn -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataDeclRn -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataDeclRn -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
gmapT :: (forall b. Data b => b -> b) -> DataDeclRn -> DataDeclRn
$cgmapT :: (forall b. Data b => b -> b) -> DataDeclRn -> DataDeclRn
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDeclRn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDeclRn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclRn)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclRn)
dataTypeOf :: DataDeclRn -> DataType
$cdataTypeOf :: DataDeclRn -> DataType
toConstr :: DataDeclRn -> Constr
$ctoConstr :: DataDeclRn -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclRn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclRn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclRn -> c DataDeclRn
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclRn -> c DataDeclRn
Data
type instance XClassDecl GhcPs = (EpAnn [AddEpAnn], AnnSortKey)
type instance XClassDecl GhcRn = NameSet
type instance XClassDecl GhcTc = NameSet
type instance XXTyClDecl (GhcPass _) = DataConCantHappen
type instance XCTyFamInstDecl (GhcPass _) = EpAnn [AddEpAnn]
type instance XXTyFamInstDecl (GhcPass _) = DataConCantHappen
pprFlavour :: FamilyInfo pass -> SDoc
pprFlavour :: forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo pass
DataFamily = forall doc. IsLine doc => String -> doc
text String
"data"
pprFlavour FamilyInfo pass
OpenTypeFamily = forall doc. IsLine doc => String -> doc
text String
"type"
pprFlavour (ClosedTypeFamily {}) = forall doc. IsLine doc => String -> doc
text String
"type"
instance Outputable (FamilyInfo pass) where
ppr :: FamilyInfo pass -> SDoc
ppr FamilyInfo pass
info = forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo pass
info forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"family"
tyFamInstDeclName :: Anno (IdGhcP p) ~ SrcSpanAnnN
=> TyFamInstDecl (GhcPass p) -> IdP (GhcPass p)
tyFamInstDeclName :: forall (p :: Pass).
(Anno (IdGhcP p) ~ SrcSpanAnnN) =>
TyFamInstDecl (GhcPass p) -> IdP (GhcPass p)
tyFamInstDeclName = forall l e. GenLocated l e -> e
unLoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: Pass).
(Anno (IdGhcP p) ~ SrcSpanAnnN) =>
TyFamInstDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
tyFamInstDeclLName
tyFamInstDeclLName :: Anno (IdGhcP p) ~ SrcSpanAnnN
=> TyFamInstDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
tyFamInstDeclLName :: forall (p :: Pass).
(Anno (IdGhcP p) ~ SrcSpanAnnN) =>
TyFamInstDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
tyFamInstDeclLName (TyFamInstDecl { tfid_eqn :: forall pass. TyFamInstDecl pass -> TyFamInstEqn pass
tfid_eqn = FamEqn { feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_tycon = LIdP (GhcPass p)
ln }})
= LIdP (GhcPass p)
ln
tyClDeclLName :: Anno (IdGhcP p) ~ SrcSpanAnnN
=> TyClDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
tyClDeclLName :: forall (p :: Pass).
(Anno (IdGhcP p) ~ SrcSpanAnnN) =>
TyClDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
tyClDeclLName (FamDecl { tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam = FamilyDecl (GhcPass p)
fd }) = forall (p :: Pass).
FamilyDecl (GhcPass p) -> XRec (GhcPass p) (IdP (GhcPass p))
familyDeclLName FamilyDecl (GhcPass p)
fd
tyClDeclLName (SynDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ln }) = LIdP (GhcPass p)
ln
tyClDeclLName (DataDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ln }) = LIdP (GhcPass p)
ln
tyClDeclLName (ClassDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ln }) = LIdP (GhcPass p)
ln
countTyClDecls :: [TyClDecl pass] -> (Int, Int, Int, Int, Int)
countTyClDecls :: forall pass. [TyClDecl pass] -> (Int, Int, Int, Int, Int)
countTyClDecls [TyClDecl pass]
decls
= (forall a. (a -> Bool) -> [a] -> Int
count forall pass. TyClDecl pass -> Bool
isClassDecl [TyClDecl pass]
decls,
forall a. (a -> Bool) -> [a] -> Int
count forall pass. TyClDecl pass -> Bool
isSynDecl [TyClDecl pass]
decls,
forall a. (a -> Bool) -> [a] -> Int
count forall pass. TyClDecl pass -> Bool
isDataTy [TyClDecl pass]
decls,
forall a. (a -> Bool) -> [a] -> Int
count forall pass. TyClDecl pass -> Bool
isNewTy [TyClDecl pass]
decls,
forall a. (a -> Bool) -> [a] -> Int
count forall pass. TyClDecl pass -> Bool
isFamilyDecl [TyClDecl pass]
decls)
where
isDataTy :: TyClDecl pass -> Bool
isDataTy DataDecl{ tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn { dd_cons :: forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons = DataTypeCons Bool
_ [LConDecl pass]
_ } } = Bool
True
isDataTy TyClDecl pass
_ = Bool
False
isNewTy :: TyClDecl pass -> Bool
isNewTy DataDecl{ tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn { dd_cons :: forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons = NewTypeCon LConDecl pass
_ } } = Bool
True
isNewTy TyClDecl pass
_ = Bool
False
tcdName :: Anno (IdGhcP p) ~ SrcSpanAnnN
=> TyClDecl (GhcPass p) -> IdP (GhcPass p)
tcdName :: forall (p :: Pass).
(Anno (IdGhcP p) ~ SrcSpanAnnN) =>
TyClDecl (GhcPass p) -> IdP (GhcPass p)
tcdName = forall l e. GenLocated l e -> e
unLoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: Pass).
(Anno (IdGhcP p) ~ SrcSpanAnnN) =>
TyClDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
tyClDeclLName
hsDeclHasCusk :: TyClDecl GhcRn -> Bool
hsDeclHasCusk :: TyClDecl GhcRn -> Bool
hsDeclHasCusk (FamDecl { tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam =
FamilyDecl { fdInfo :: forall pass. FamilyDecl pass -> FamilyInfo pass
fdInfo = FamilyInfo GhcRn
fam_info
, fdTyVars :: forall pass. FamilyDecl pass -> LHsQTyVars pass
fdTyVars = LHsQTyVars GhcRn
tyvars
, fdResultSig :: forall pass. FamilyDecl pass -> LFamilyResultSig pass
fdResultSig = L SrcAnn NoEpAnns
_ FamilyResultSig GhcRn
resultSig } }) =
case FamilyInfo GhcRn
fam_info of
ClosedTypeFamily {} -> forall (p :: Pass). LHsQTyVars (GhcPass p) -> Bool
hsTvbAllKinded LHsQTyVars GhcRn
tyvars
Bool -> Bool -> Bool
&& forall a. Maybe a -> Bool
isJust (forall (p :: Pass).
FamilyResultSig (GhcPass p) -> Maybe (LHsKind (GhcPass p))
famResultKindSignature FamilyResultSig GhcRn
resultSig)
FamilyInfo GhcRn
_ -> Bool
True
hsDeclHasCusk (SynDecl { tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
tyvars, tcdRhs :: forall pass. TyClDecl pass -> LHsType pass
tcdRhs = LHsType GhcRn
rhs })
= forall (p :: Pass). LHsQTyVars (GhcPass p) -> Bool
hsTvbAllKinded LHsQTyVars GhcRn
tyvars Bool -> Bool -> Bool
&& forall a. Maybe a -> Bool
isJust (forall (p :: Pass).
LHsType (GhcPass p) -> Maybe (LHsType (GhcPass p))
hsTyKindSig LHsType GhcRn
rhs)
hsDeclHasCusk (DataDecl { tcdDExt :: forall pass. TyClDecl pass -> XDataDecl pass
tcdDExt = DataDeclRn { tcdDataCusk :: DataDeclRn -> Bool
tcdDataCusk = Bool
cusk }}) = Bool
cusk
hsDeclHasCusk (ClassDecl { tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
tyvars }) = forall (p :: Pass). LHsQTyVars (GhcPass p) -> Bool
hsTvbAllKinded LHsQTyVars GhcRn
tyvars
instance (OutputableBndrId p) => Outputable (TyClDecl (GhcPass p)) where
ppr :: TyClDecl (GhcPass p) -> SDoc
ppr (FamDecl { tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam = FamilyDecl (GhcPass p)
decl }) = forall a. Outputable a => a -> SDoc
ppr FamilyDecl (GhcPass p)
decl
ppr (SynDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ltycon, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars (GhcPass p)
tyvars, tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity
, tcdRhs :: forall pass. TyClDecl pass -> LHsType pass
tcdRhs = LHsType (GhcPass p)
rhs })
= SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"type" forall doc. IsLine doc => doc -> doc -> doc
<+>
forall (p :: Pass).
OutputableBndrId p =>
XRec (GhcPass p) (IdP (GhcPass p))
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
ltycon LHsQTyVars (GhcPass p)
tyvars LexicalFixity
fixity forall a. Maybe a
Nothing forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => doc
equals)
Int
4 (forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
rhs)
ppr (DataDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ltycon, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars (GhcPass p)
tyvars, tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity
, tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn (GhcPass p)
defn })
= forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
pp_data_defn (forall (p :: Pass).
OutputableBndrId p =>
XRec (GhcPass p) (IdP (GhcPass p))
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
ltycon LHsQTyVars (GhcPass p)
tyvars LexicalFixity
fixity) HsDataDefn (GhcPass p)
defn
ppr (ClassDecl {tcdCtxt :: forall pass. TyClDecl pass -> Maybe (LHsContext pass)
tcdCtxt = Maybe (LHsContext (GhcPass p))
context, tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
lclas, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars (GhcPass p)
tyvars,
tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity,
tcdFDs :: forall pass. TyClDecl pass -> [LHsFunDep pass]
tcdFDs = [LHsFunDep (GhcPass p)]
fds,
tcdSigs :: forall pass. TyClDecl pass -> [LSig pass]
tcdSigs = [LSig (GhcPass p)]
sigs, tcdMeths :: forall pass. TyClDecl pass -> LHsBinds pass
tcdMeths = LHsBinds (GhcPass p)
methods,
tcdATs :: forall pass. TyClDecl pass -> [LFamilyDecl pass]
tcdATs = [LFamilyDecl (GhcPass p)]
ats, tcdATDefs :: forall pass. TyClDecl pass -> [LTyFamDefltDecl pass]
tcdATDefs = [LTyFamDefltDecl (GhcPass p)]
at_defs})
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LSig (GhcPass p)]
sigs Bool -> Bool -> Bool
&& forall a. Bag a -> Bool
isEmptyBag LHsBinds (GhcPass p)
methods Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LFamilyDecl (GhcPass p)]
ats Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LTyFamDefltDecl (GhcPass p)]
at_defs
= SDoc
top_matter
| Bool
otherwise
= forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
top_matter forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"where"
, Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
pprDeclList (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) [LFamilyDecl (GhcPass p)]
ats forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
OutputableBndrId p =>
TyFamDefltDecl (GhcPass p) -> SDoc
pprTyFamDefltDecl forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LTyFamDefltDecl (GhcPass p)]
at_defs forall a. [a] -> [a] -> [a]
++
forall (idL :: Pass) (idR :: Pass) (id2 :: Pass).
(OutputableBndrId idL, OutputableBndrId idR,
OutputableBndrId id2) =>
LHsBindsLR (GhcPass idL) (GhcPass idR)
-> [LSig (GhcPass id2)] -> [SDoc]
pprLHsBindsForUser LHsBinds (GhcPass p)
methods [LSig (GhcPass p)]
sigs) ]
where
top_matter :: SDoc
top_matter = forall doc. IsLine doc => String -> doc
text String
"class"
forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
XRec (GhcPass p) (IdP (GhcPass p))
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
lclas LHsQTyVars (GhcPass p)
tyvars LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
context
forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
[FunDep (GhcPass p)] -> SDoc
pprFundeps (forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc [LHsFunDep (GhcPass p)]
fds)
instance OutputableBndrId p
=> Outputable (TyClGroup (GhcPass p)) where
ppr :: TyClGroup (GhcPass p) -> SDoc
ppr (TyClGroup { group_tyclds :: forall pass. TyClGroup pass -> [LTyClDecl pass]
group_tyclds = [LTyClDecl (GhcPass p)]
tyclds
, group_roles :: forall pass. TyClGroup pass -> [LRoleAnnotDecl pass]
group_roles = [LRoleAnnotDecl (GhcPass p)]
roles
, group_kisigs :: forall pass. TyClGroup pass -> [LStandaloneKindSig pass]
group_kisigs = [LStandaloneKindSig (GhcPass p)]
kisigs
, group_instds :: forall pass. TyClGroup pass -> [LInstDecl pass]
group_instds = [LInstDecl (GhcPass p)]
instds
}
)
= SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"TyClGroup") Int
2 forall a b. (a -> b) -> a -> b
$
forall a. Outputable a => a -> SDoc
ppr [LStandaloneKindSig (GhcPass p)]
kisigs forall doc. IsDoc doc => doc -> doc -> doc
$$
forall a. Outputable a => a -> SDoc
ppr [LTyClDecl (GhcPass p)]
tyclds forall doc. IsDoc doc => doc -> doc -> doc
$$
forall a. Outputable a => a -> SDoc
ppr [LRoleAnnotDecl (GhcPass p)]
roles forall doc. IsDoc doc => doc -> doc -> doc
$$
forall a. Outputable a => a -> SDoc
ppr [LInstDecl (GhcPass p)]
instds
pp_vanilla_decl_head :: (OutputableBndrId p)
=> XRec (GhcPass p) (IdP (GhcPass p))
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head :: forall (p :: Pass).
OutputableBndrId p =>
XRec (GhcPass p) (IdP (GhcPass p))
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head XRec (GhcPass p) (IdP (GhcPass p))
thing (HsQTvs { hsq_explicit :: forall pass. LHsQTyVars pass -> [LHsTyVarBndr () pass]
hsq_explicit = [LHsTyVarBndr () (GhcPass p)]
tyvars }) LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
context
= forall doc. IsLine doc => [doc] -> doc
hsep [forall (p :: Pass).
OutputableBndrId p =>
Maybe (LHsContext (GhcPass p)) -> SDoc
pprLHsContext Maybe (LHsContext (GhcPass p))
context, [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))] -> SDoc
pp_tyvars [LHsTyVarBndr () (GhcPass p)]
tyvars]
where
pp_tyvars :: [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))] -> SDoc
pp_tyvars (GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
varl:[GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))]
varsr)
| LexicalFixity
fixity forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix, GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
varr:varsr' :: [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))]
varsr'@(GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
_:[GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))]
_) <- [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))]
varsr
= forall doc. IsLine doc => [doc] -> doc
hsep [forall doc. IsLine doc => Char -> doc
char Char
'(',forall a. Outputable a => a -> SDoc
ppr (forall l e. GenLocated l e -> e
unLoc GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
varl), forall a. OutputableBndr a => a -> SDoc
pprInfixOcc (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (IdP (GhcPass p))
thing)
, (forall a. Outputable a => a -> SDoc
pprforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall l e. GenLocated l e -> e
unLoc) GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
varr, forall doc. IsLine doc => Char -> doc
char Char
')'
, forall doc. IsLine doc => [doc] -> doc
hsep (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Outputable a => a -> SDoc
pprforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall l e. GenLocated l e -> e
unLoc) [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))]
varsr')]
| LexicalFixity
fixity forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix
= forall doc. IsLine doc => [doc] -> doc
hsep [forall a. Outputable a => a -> SDoc
ppr (forall l e. GenLocated l e -> e
unLoc GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
varl), forall a. OutputableBndr a => a -> SDoc
pprInfixOcc (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (IdP (GhcPass p))
thing)
, forall doc. IsLine doc => [doc] -> doc
hsep (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Outputable a => a -> SDoc
pprforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall l e. GenLocated l e -> e
unLoc) [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))]
varsr)]
| Bool
otherwise = forall doc. IsLine doc => [doc] -> doc
hsep [ forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (IdP (GhcPass p))
thing)
, forall doc. IsLine doc => [doc] -> doc
hsep (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Outputable a => a -> SDoc
pprforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall l e. GenLocated l e -> e
unLoc) (GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
varlforall a. a -> [a] -> [a]
:[GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))]
varsr))]
pp_tyvars [] = forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (IdP (GhcPass p))
thing)
pprTyClDeclFlavour :: TyClDecl (GhcPass p) -> SDoc
pprTyClDeclFlavour :: forall (p :: Pass). TyClDecl (GhcPass p) -> SDoc
pprTyClDeclFlavour (ClassDecl {}) = forall doc. IsLine doc => String -> doc
text String
"class"
pprTyClDeclFlavour (SynDecl {}) = forall doc. IsLine doc => String -> doc
text String
"type"
pprTyClDeclFlavour (FamDecl { tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam = FamilyDecl { fdInfo :: forall pass. FamilyDecl pass -> FamilyInfo pass
fdInfo = FamilyInfo (GhcPass p)
info }})
= forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo (GhcPass p)
info forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"family"
pprTyClDeclFlavour (DataDecl { tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn { dd_cons :: forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons = DataDefnCons (LConDecl (GhcPass p))
nd } })
= forall a. Outputable a => a -> SDoc
ppr (forall a. DataDefnCons a -> NewOrData
dataDefnConsNewOrData DataDefnCons (LConDecl (GhcPass p))
nd)
instance OutputableBndrId p => Outputable (FunDep (GhcPass p)) where
ppr :: FunDep (GhcPass p) -> SDoc
ppr = forall (p :: Pass).
OutputableBndrId p =>
FunDep (GhcPass p) -> SDoc
pprFunDep
type instance XCFunDep (GhcPass _) = EpAnn [AddEpAnn]
type instance XXFunDep (GhcPass _) = DataConCantHappen
pprFundeps :: OutputableBndrId p => [FunDep (GhcPass p)] -> SDoc
pprFundeps :: forall (p :: Pass).
OutputableBndrId p =>
[FunDep (GhcPass p)] -> SDoc
pprFundeps [] = forall doc. IsOutput doc => doc
empty
pprFundeps [FunDep (GhcPass p)]
fds = forall doc. IsLine doc => [doc] -> doc
hsep (forall doc. IsLine doc => doc
vbar forall a. a -> [a] -> [a]
: forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map forall (p :: Pass).
OutputableBndrId p =>
FunDep (GhcPass p) -> SDoc
pprFunDep [FunDep (GhcPass p)]
fds))
pprFunDep :: OutputableBndrId p => FunDep (GhcPass p) -> SDoc
pprFunDep :: forall (p :: Pass).
OutputableBndrId p =>
FunDep (GhcPass p) -> SDoc
pprFunDep (FunDep XCFunDep (GhcPass p)
_ [LIdP (GhcPass p)]
us [LIdP (GhcPass p)]
vs) = forall doc. IsLine doc => [doc] -> doc
hsep [forall a. Outputable a => [a] -> SDoc
interppSP [LIdP (GhcPass p)]
us, SDoc
arrow, forall a. Outputable a => [a] -> SDoc
interppSP [LIdP (GhcPass p)]
vs]
type instance XCTyClGroup (GhcPass _) = NoExtField
type instance XXTyClGroup (GhcPass _) = DataConCantHappen
type instance XNoSig (GhcPass _) = NoExtField
type instance XCKindSig (GhcPass _) = NoExtField
type instance XTyVarSig (GhcPass _) = NoExtField
type instance XXFamilyResultSig (GhcPass _) = DataConCantHappen
type instance XCFamilyDecl (GhcPass _) = EpAnn [AddEpAnn]
type instance XXFamilyDecl (GhcPass _) = DataConCantHappen
familyDeclLName :: FamilyDecl (GhcPass p) -> XRec (GhcPass p) (IdP (GhcPass p))
familyDeclLName :: forall (p :: Pass).
FamilyDecl (GhcPass p) -> XRec (GhcPass p) (IdP (GhcPass p))
familyDeclLName (FamilyDecl { fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdLName = LIdP (GhcPass p)
n }) = LIdP (GhcPass p)
n
familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p)
familyDeclName :: forall (p :: Pass). FamilyDecl (GhcPass p) -> IdP (GhcPass p)
familyDeclName = forall l e. GenLocated l e -> e
unLoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: Pass).
FamilyDecl (GhcPass p) -> XRec (GhcPass p) (IdP (GhcPass p))
familyDeclLName
famResultKindSignature :: FamilyResultSig (GhcPass p) -> Maybe (LHsKind (GhcPass p))
famResultKindSignature :: forall (p :: Pass).
FamilyResultSig (GhcPass p) -> Maybe (LHsKind (GhcPass p))
famResultKindSignature (NoSig XNoSig (GhcPass p)
_) = forall a. Maybe a
Nothing
famResultKindSignature (KindSig XCKindSig (GhcPass p)
_ LHsKind (GhcPass p)
ki) = forall a. a -> Maybe a
Just LHsKind (GhcPass p)
ki
famResultKindSignature (TyVarSig XTyVarSig (GhcPass p)
_ LHsTyVarBndr () (GhcPass p)
bndr) =
case forall l e. GenLocated l e -> e
unLoc LHsTyVarBndr () (GhcPass p)
bndr of
UserTyVar XUserTyVar (GhcPass p)
_ ()
_ LIdP (GhcPass p)
_ -> forall a. Maybe a
Nothing
KindedTyVar XKindedTyVar (GhcPass p)
_ ()
_ LIdP (GhcPass p)
_ LHsKind (GhcPass p)
ki -> forall a. a -> Maybe a
Just LHsKind (GhcPass p)
ki
resultVariableName :: FamilyResultSig (GhcPass a) -> Maybe (IdP (GhcPass a))
resultVariableName :: forall (a :: Pass).
FamilyResultSig (GhcPass a) -> Maybe (IdP (GhcPass a))
resultVariableName (TyVarSig XTyVarSig (GhcPass a)
_ LHsTyVarBndr () (GhcPass a)
sig) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall flag (p :: Pass).
LHsTyVarBndr flag (GhcPass p) -> IdP (GhcPass p)
hsLTyVarName LHsTyVarBndr () (GhcPass a)
sig
resultVariableName FamilyResultSig (GhcPass a)
_ = forall a. Maybe a
Nothing
type instance XCInjectivityAnn (GhcPass _) = EpAnn [AddEpAnn]
type instance XXInjectivityAnn (GhcPass _) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (FamilyDecl (GhcPass p)) where
ppr :: FamilyDecl (GhcPass p) -> SDoc
ppr (FamilyDecl { fdInfo :: forall pass. FamilyDecl pass -> FamilyInfo pass
fdInfo = FamilyInfo (GhcPass p)
info, fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdLName = LIdP (GhcPass p)
ltycon
, fdTopLevel :: forall pass. FamilyDecl pass -> TopLevelFlag
fdTopLevel = TopLevelFlag
top_level
, fdTyVars :: forall pass. FamilyDecl pass -> LHsQTyVars pass
fdTyVars = LHsQTyVars (GhcPass p)
tyvars
, fdFixity :: forall pass. FamilyDecl pass -> LexicalFixity
fdFixity = LexicalFixity
fixity
, fdResultSig :: forall pass. FamilyDecl pass -> LFamilyResultSig pass
fdResultSig = L SrcAnn NoEpAnns
_ FamilyResultSig (GhcPass p)
result
, fdInjectivityAnn :: forall pass. FamilyDecl pass -> Maybe (LInjectivityAnn pass)
fdInjectivityAnn = Maybe (LInjectivityAnn (GhcPass p))
mb_inj })
= forall doc. IsDoc doc => [doc] -> doc
vcat [ forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo (GhcPass p)
info forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_top_level forall doc. IsLine doc => doc -> doc -> doc
<+>
forall (p :: Pass).
OutputableBndrId p =>
XRec (GhcPass p) (IdP (GhcPass p))
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
ltycon LHsQTyVars (GhcPass p)
tyvars LexicalFixity
fixity forall a. Maybe a
Nothing forall doc. IsLine doc => doc -> doc -> doc
<+>
SDoc
pp_kind forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_inj forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_where
, Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$ SDoc
pp_eqns ]
where
pp_top_level :: SDoc
pp_top_level = case TopLevelFlag
top_level of
TopLevelFlag
TopLevel -> forall doc. IsLine doc => String -> doc
text String
"family"
TopLevelFlag
NotTopLevel -> forall doc. IsOutput doc => doc
empty
pp_kind :: SDoc
pp_kind = case FamilyResultSig (GhcPass p)
result of
NoSig XNoSig (GhcPass p)
_ -> forall doc. IsOutput doc => doc
empty
KindSig XCKindSig (GhcPass p)
_ LHsKind (GhcPass p)
kind -> SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsKind (GhcPass p)
kind
TyVarSig XTyVarSig (GhcPass p)
_ LHsTyVarBndr () (GhcPass p)
tv_bndr -> forall doc. IsLine doc => String -> doc
text String
"=" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsTyVarBndr () (GhcPass p)
tv_bndr
pp_inj :: SDoc
pp_inj = case Maybe (LInjectivityAnn (GhcPass p))
mb_inj of
Just (L SrcAnn NoEpAnns
_ (InjectivityAnn XCInjectivityAnn (GhcPass p)
_ LIdP (GhcPass p)
lhs [LIdP (GhcPass p)]
rhs)) ->
forall doc. IsLine doc => [doc] -> doc
hsep [ forall doc. IsLine doc => doc
vbar, forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
lhs, forall doc. IsLine doc => String -> doc
text String
"->", forall doc. IsLine doc => [doc] -> doc
hsep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LIdP (GhcPass p)]
rhs) ]
Maybe (LInjectivityAnn (GhcPass p))
Nothing -> forall doc. IsOutput doc => doc
empty
(SDoc
pp_where, SDoc
pp_eqns) = case FamilyInfo (GhcPass p)
info of
ClosedTypeFamily Maybe [LTyFamInstEqn (GhcPass p)]
mb_eqns ->
( forall doc. IsLine doc => String -> doc
text String
"where"
, case Maybe [LTyFamInstEqn (GhcPass p)]
mb_eqns of
Maybe [LTyFamInstEqn (GhcPass p)]
Nothing -> forall doc. IsLine doc => String -> doc
text String
".."
Just [LTyFamInstEqn (GhcPass p)]
eqns -> forall doc. IsDoc doc => [doc] -> doc
vcat forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
OutputableBndrId p =>
TyFamInstEqn (GhcPass p) -> SDoc
ppr_fam_inst_eqn forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LTyFamInstEqn (GhcPass p)]
eqns )
FamilyInfo (GhcPass p)
_ -> (forall doc. IsOutput doc => doc
empty, forall doc. IsOutput doc => doc
empty)
type instance XCHsDataDefn (GhcPass _) = NoExtField
type instance XXHsDataDefn (GhcPass _) = DataConCantHappen
type instance XCHsDerivingClause (GhcPass _) = EpAnn [AddEpAnn]
type instance XXHsDerivingClause (GhcPass _) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (HsDerivingClause (GhcPass p)) where
ppr :: HsDerivingClause (GhcPass p) -> SDoc
ppr (HsDerivingClause { deriv_clause_strategy :: forall pass. HsDerivingClause pass -> Maybe (LDerivStrategy pass)
deriv_clause_strategy = Maybe (LDerivStrategy (GhcPass p))
dcs
, deriv_clause_tys :: forall pass. HsDerivingClause pass -> LDerivClauseTys pass
deriv_clause_tys = L SrcSpanAnnC
_ DerivClauseTys (GhcPass p)
dct })
= forall doc. IsLine doc => [doc] -> doc
hsep [ forall doc. IsLine doc => String -> doc
text String
"deriving"
, SDoc
pp_strat_before
, forall a. Outputable a => a -> SDoc
ppr DerivClauseTys (GhcPass p)
dct
, SDoc
pp_strat_after ]
where
(SDoc
pp_strat_before, SDoc
pp_strat_after) =
case Maybe (LDerivStrategy (GhcPass p))
dcs of
Just (L SrcAnn NoEpAnns
_ via :: DerivStrategy (GhcPass p)
via@ViaStrategy{}) -> (forall doc. IsOutput doc => doc
empty, forall a. Outputable a => a -> SDoc
ppr DerivStrategy (GhcPass p)
via)
Maybe (LDerivStrategy (GhcPass p))
_ -> (forall (p :: Pass).
OutputableBndrId p =>
Maybe (LDerivStrategy (GhcPass p)) -> SDoc
ppDerivStrategy Maybe (LDerivStrategy (GhcPass p))
dcs, forall doc. IsOutput doc => doc
empty)
derivStrategyName :: DerivStrategy a -> SDoc
derivStrategyName :: forall a. DerivStrategy a -> SDoc
derivStrategyName = forall doc. IsLine doc => String -> doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {pass}. DerivStrategy pass -> String
go
where
go :: DerivStrategy pass -> String
go StockStrategy {} = String
"stock"
go AnyclassStrategy {} = String
"anyclass"
go NewtypeStrategy {} = String
"newtype"
go ViaStrategy {} = String
"via"
type instance XDctSingle (GhcPass _) = NoExtField
type instance XDctMulti (GhcPass _) = NoExtField
type instance XXDerivClauseTys (GhcPass _) = DataConCantHappen
instance OutputableBndrId p => Outputable (DerivClauseTys (GhcPass p)) where
ppr :: DerivClauseTys (GhcPass p) -> SDoc
ppr (DctSingle XDctSingle (GhcPass p)
_ LHsSigType (GhcPass p)
ty) = forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
ty
ppr (DctMulti XDctMulti (GhcPass p)
_ [LHsSigType (GhcPass p)]
tys) = forall doc. IsLine doc => doc -> doc
parens (forall a. Outputable a => [a] -> SDoc
interpp'SP [LHsSigType (GhcPass p)]
tys)
type instance XStandaloneKindSig GhcPs = EpAnn [AddEpAnn]
type instance XStandaloneKindSig GhcRn = NoExtField
type instance XStandaloneKindSig GhcTc = NoExtField
type instance XXStandaloneKindSig (GhcPass p) = DataConCantHappen
standaloneKindSigName :: StandaloneKindSig (GhcPass p) -> IdP (GhcPass p)
standaloneKindSigName :: forall (p :: Pass).
StandaloneKindSig (GhcPass p) -> IdP (GhcPass p)
standaloneKindSigName (StandaloneKindSig XStandaloneKindSig (GhcPass p)
_ LIdP (GhcPass p)
lname LHsSigType (GhcPass p)
_) = forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
lname
type instance XConDeclGADT (GhcPass _) = EpAnn [AddEpAnn]
type instance XConDeclH98 (GhcPass _) = EpAnn [AddEpAnn]
type instance XXConDecl (GhcPass _) = DataConCantHappen
getConNames :: ConDecl GhcRn -> [LocatedN Name]
getConNames :: ConDecl GhcRn -> [LocatedN SplicePointName]
getConNames ConDeclH98 {con_name :: forall pass. ConDecl pass -> LIdP pass
con_name = LIdP GhcRn
name} = [LIdP GhcRn
name]
getConNames ConDeclGADT {con_names :: forall pass. ConDecl pass -> NonEmpty (LIdP pass)
con_names = NonEmpty (LIdP GhcRn)
names} = forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (LIdP GhcRn)
names
getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (LocatedL [LConDeclField GhcRn])
getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (LocatedL [LConDeclField GhcRn])
getRecConArgs_maybe (ConDeclH98{con_args :: forall pass. ConDecl pass -> HsConDeclH98Details pass
con_args = HsConDeclH98Details GhcRn
args}) = case HsConDeclH98Details GhcRn
args of
PrefixCon{} -> forall a. Maybe a
Nothing
RecCon XRec GhcRn [LConDeclField GhcRn]
flds -> forall a. a -> Maybe a
Just XRec GhcRn [LConDeclField GhcRn]
flds
InfixCon{} -> forall a. Maybe a
Nothing
getRecConArgs_maybe (ConDeclGADT{con_g_args :: forall pass. ConDecl pass -> HsConDeclGADTDetails pass
con_g_args = HsConDeclGADTDetails GhcRn
args}) = case HsConDeclGADTDetails GhcRn
args of
PrefixConGADT{} -> forall a. Maybe a
Nothing
RecConGADT XRec GhcRn [LConDeclField GhcRn]
flds LHsUniToken "->" "\8594" GhcRn
_ -> forall a. a -> Maybe a
Just XRec GhcRn [LConDeclField GhcRn]
flds
hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)]
hsConDeclTheta :: forall (p :: Pass).
Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)]
hsConDeclTheta Maybe (LHsContext (GhcPass p))
Nothing = []
hsConDeclTheta (Just (L SrcSpanAnnC
_ [GenLocated SrcSpanAnnA (HsType (GhcPass p))]
theta)) = [GenLocated SrcSpanAnnA (HsType (GhcPass p))]
theta
ppDataDefnHeader
:: (OutputableBndrId p)
=> (Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p)
-> SDoc
Maybe (LHsContext (GhcPass p)) -> SDoc
pp_hdr HsDataDefn
{ dd_ctxt :: forall pass. HsDataDefn pass -> Maybe (LHsContext pass)
dd_ctxt = Maybe (LHsContext (GhcPass p))
context
, dd_cType :: forall pass. HsDataDefn pass -> Maybe (XRec pass CType)
dd_cType = Maybe (XRec (GhcPass p) CType)
mb_ct
, dd_kindSig :: forall pass. HsDataDefn pass -> Maybe (LHsKind pass)
dd_kindSig = Maybe (LHsKind (GhcPass p))
mb_sig
, dd_cons :: forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons = DataDefnCons (LConDecl (GhcPass p))
condecls }
= SDoc
pp_type forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr (forall a. DataDefnCons a -> NewOrData
dataDefnConsNewOrData DataDefnCons (LConDecl (GhcPass p))
condecls) forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_ct forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe (LHsContext (GhcPass p)) -> SDoc
pp_hdr Maybe (LHsContext (GhcPass p))
context forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_sig
where
pp_type :: SDoc
pp_type
| forall a. DataDefnCons a -> Bool
isTypeDataDefnCons DataDefnCons (LConDecl (GhcPass p))
condecls = forall doc. IsLine doc => String -> doc
text String
"type"
| Bool
otherwise = forall doc. IsOutput doc => doc
empty
pp_ct :: SDoc
pp_ct = case Maybe (XRec (GhcPass p) CType)
mb_ct of
Maybe (XRec (GhcPass p) CType)
Nothing -> forall doc. IsOutput doc => doc
empty
Just XRec (GhcPass p) CType
ct -> forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) CType
ct
pp_sig :: SDoc
pp_sig = case Maybe (LHsKind (GhcPass p))
mb_sig of
Maybe (LHsKind (GhcPass p))
Nothing -> forall doc. IsOutput doc => doc
empty
Just LHsKind (GhcPass p)
kind -> SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsKind (GhcPass p)
kind
pp_data_defn :: (OutputableBndrId p)
=> (Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p)
-> SDoc
pp_data_defn :: forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
pp_data_defn Maybe (LHsContext (GhcPass p)) -> SDoc
pp_hdr defn :: HsDataDefn (GhcPass p)
defn@HsDataDefn
{ dd_cons :: forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons = DataDefnCons (LConDecl (GhcPass p))
condecls
, dd_derivs :: forall pass. HsDataDefn pass -> HsDeriving pass
dd_derivs = HsDeriving (GhcPass p)
derivings }
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null DataDefnCons (LConDecl (GhcPass p))
condecls
= forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
ppDataDefnHeader Maybe (LHsContext (GhcPass p)) -> SDoc
pp_hdr HsDataDefn (GhcPass p)
defn forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => [a] -> SDoc
pp_derivings HsDeriving (GhcPass p)
derivings
| Bool
otherwise
= SDoc -> Int -> SDoc -> SDoc
hang (forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
ppDataDefnHeader Maybe (LHsContext (GhcPass p)) -> SDoc
pp_hdr HsDataDefn (GhcPass p)
defn) Int
2 (forall (p :: Pass).
OutputableBndrId p =>
[LConDecl (GhcPass p)] -> SDoc
pp_condecls (forall (t :: * -> *) a. Foldable t => t a -> [a]
toList DataDefnCons (LConDecl (GhcPass p))
condecls) forall doc. IsDoc doc => doc -> doc -> doc
$$ forall a. Outputable a => [a] -> SDoc
pp_derivings HsDeriving (GhcPass p)
derivings)
where
pp_derivings :: [a] -> SDoc
pp_derivings [a]
ds = forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [a]
ds)
instance OutputableBndrId p
=> Outputable (HsDataDefn (GhcPass p)) where
ppr :: HsDataDefn (GhcPass p) -> SDoc
ppr HsDataDefn (GhcPass p)
d = forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
pp_data_defn (\Maybe (LHsContext (GhcPass p))
_ -> forall doc. IsLine doc => String -> doc
text String
"Naked HsDataDefn") HsDataDefn (GhcPass p)
d
instance OutputableBndrId p
=> Outputable (StandaloneKindSig (GhcPass p)) where
ppr :: StandaloneKindSig (GhcPass p) -> SDoc
ppr (StandaloneKindSig XStandaloneKindSig (GhcPass p)
_ LIdP (GhcPass p)
v LHsSigType (GhcPass p)
ki)
= forall doc. IsLine doc => String -> doc
text String
"type" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
v) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"::" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
ki
pp_condecls :: forall p. OutputableBndrId p => [LConDecl (GhcPass p)] -> SDoc
pp_condecls :: forall (p :: Pass).
OutputableBndrId p =>
[LConDecl (GhcPass p)] -> SDoc
pp_condecls [LConDecl (GhcPass p)]
cs
| forall (f :: * -> *) l pass.
Foldable f =>
f (GenLocated l (ConDecl pass)) -> Bool
anyLConIsGadt [LConDecl (GhcPass p)]
cs
= SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"where") Int
2 (forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LConDecl (GhcPass p)]
cs))
| Bool
otherwise
= forall doc. IsLine doc => doc
equals forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
sep (forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate (forall doc. IsLine doc => String -> doc
text String
" |") (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LConDecl (GhcPass p)]
cs))
instance (OutputableBndrId p) => Outputable (ConDecl (GhcPass p)) where
ppr :: ConDecl (GhcPass p) -> SDoc
ppr = forall (p :: Pass).
OutputableBndrId p =>
ConDecl (GhcPass p) -> SDoc
pprConDecl
pprConDecl :: forall p. OutputableBndrId p => ConDecl (GhcPass p) -> SDoc
pprConDecl :: forall (p :: Pass).
OutputableBndrId p =>
ConDecl (GhcPass p) -> SDoc
pprConDecl (ConDeclH98 { con_name :: forall pass. ConDecl pass -> LIdP pass
con_name = L Anno (IdGhcP p)
_ IdGhcP p
con
, con_ex_tvs :: forall pass. ConDecl pass -> [LHsTyVarBndr Specificity pass]
con_ex_tvs = [LHsTyVarBndr Specificity (GhcPass p)]
ex_tvs
, con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext (GhcPass p))
mcxt
, con_args :: forall pass. ConDecl pass -> HsConDeclH98Details pass
con_args = HsConDeclH98Details (GhcPass p)
args
, con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
con_doc = Maybe (LHsDoc (GhcPass p))
doc })
= forall name. Maybe (LHsDoc name) -> SDoc -> SDoc
pprMaybeWithDoc Maybe (LHsDoc (GhcPass p))
doc forall a b. (a -> b) -> a -> b
$
forall doc. IsLine doc => [doc] -> doc
sep [ forall (p :: Pass).
OutputableBndrId p =>
HsForAllTelescope (GhcPass p)
-> Maybe (LHsContext (GhcPass p)) -> SDoc
pprHsForAll (forall (p :: Pass).
EpAnnForallTy
-> [LHsTyVarBndr Specificity (GhcPass p)]
-> HsForAllTelescope (GhcPass p)
mkHsForAllInvisTele forall a. EpAnn a
noAnn [LHsTyVarBndr Specificity (GhcPass p)]
ex_tvs) Maybe (LHsContext (GhcPass p))
mcxt
, HsConDetails
Void
(HsScaled
(GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
(GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))])
-> SDoc
ppr_details HsConDeclH98Details (GhcPass p)
args ]
where
ppr_details :: HsConDetails
Void
(HsScaled
(GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
(GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))])
-> SDoc
ppr_details (InfixCon HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
t1 HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
t2) = forall doc. IsLine doc => [doc] -> doc
hsep [forall a. Outputable a => a -> SDoc
ppr (forall pass a. HsScaled pass a -> a
hsScaledThing HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
t1),
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc IdGhcP p
con,
forall a. Outputable a => a -> SDoc
ppr (forall pass a. HsScaled pass a -> a
hsScaledThing HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
t2)]
ppr_details (PrefixCon [Void]
_ [HsScaled
(GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
tys) = forall doc. IsLine doc => [doc] -> doc
hsep (forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
con
forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
OutputableBndrId p =>
HsType (GhcPass p) -> SDoc
pprHsType forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall pass a. HsScaled pass a -> a
hsScaledThing) [HsScaled
(GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
tys)
ppr_details (RecCon GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))]
fields) = forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
con
forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
[LConDeclField (GhcPass p)] -> SDoc
pprConDeclFields (forall l e. GenLocated l e -> e
unLoc GenLocated
SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))]
fields)
pprConDecl (ConDeclGADT { con_names :: forall pass. ConDecl pass -> NonEmpty (LIdP pass)
con_names = NonEmpty (LIdP (GhcPass p))
cons, con_bndrs :: forall pass. ConDecl pass -> XRec pass (HsOuterSigTyVarBndrs pass)
con_bndrs = L SrcSpanAnnA
_ HsOuterSigTyVarBndrs (GhcPass p)
outer_bndrs
, con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext (GhcPass p))
mcxt, con_g_args :: forall pass. ConDecl pass -> HsConDeclGADTDetails pass
con_g_args = HsConDeclGADTDetails (GhcPass p)
args
, con_res_ty :: forall pass. ConDecl pass -> LHsType pass
con_res_ty = LHsType (GhcPass p)
res_ty, con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
con_doc = Maybe (LHsDoc (GhcPass p))
doc })
= forall name. Maybe (LHsDoc name) -> SDoc -> SDoc
pprMaybeWithDoc Maybe (LHsDoc (GhcPass p))
doc forall a b. (a -> b) -> a -> b
$ forall a l. OutputableBndr a => [GenLocated l a] -> SDoc
ppr_con_names (forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (LIdP (GhcPass p))
cons) forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon
forall doc. IsLine doc => doc -> doc -> doc
<+> (forall doc. IsLine doc => [doc] -> doc
sep [forall (p :: Pass).
OutputableBndrId p =>
HsOuterSigTyVarBndrs (GhcPass p) -> SDoc
pprHsOuterSigTyVarBndrs HsOuterSigTyVarBndrs (GhcPass p)
outer_bndrs forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
Maybe (LHsContext (GhcPass p)) -> SDoc
pprLHsContext Maybe (LHsContext (GhcPass p))
mcxt,
forall doc. IsLine doc => [doc] -> doc
sep (forall {p :: Pass}.
(OutputableBndr (IdGhcP p),
OutputableBndr (IdGhcP (NoGhcTcPass p)), IsPass p,
Outputable (GenLocated (Anno (IdGhcP p)) (IdGhcP p)),
Outputable
(GenLocated
(Anno (IdGhcP (NoGhcTcPass p))) (IdGhcP (NoGhcTcPass p)))) =>
HsConDeclGADTDetails (GhcPass p) -> [SDoc]
ppr_args HsConDeclGADTDetails (GhcPass p)
args forall a. [a] -> [a] -> [a]
++ [forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
res_ty]) ])
where
ppr_args :: HsConDeclGADTDetails (GhcPass p) -> [SDoc]
ppr_args (PrefixConGADT [HsScaled (GhcPass p) (LBangType (GhcPass p))]
args) = forall a b. (a -> b) -> [a] -> [b]
map (\(HsScaled HsArrow (GhcPass p)
arr GenLocated SrcSpanAnnA (HsType (GhcPass p))
t) -> forall a. Outputable a => a -> SDoc
ppr GenLocated SrcSpanAnnA (HsType (GhcPass p))
t forall doc. IsLine doc => doc -> doc -> doc
<+> forall {pass :: Pass}.
(OutputableBndr (IdGhcP pass),
OutputableBndr (IdGhcP (NoGhcTcPass pass)), IsPass pass,
Outputable (GenLocated (Anno (IdGhcP pass)) (IdGhcP pass)),
Outputable
(GenLocated
(Anno (IdGhcP (NoGhcTcPass pass))) (IdGhcP (NoGhcTcPass pass)))) =>
HsArrow (GhcPass pass) -> SDoc
ppr_arr HsArrow (GhcPass p)
arr) [HsScaled (GhcPass p) (LBangType (GhcPass p))]
args
ppr_args (RecConGADT XRec (GhcPass p) [LConDeclField (GhcPass p)]
fields LHsUniToken "->" "\8594" (GhcPass p)
_) = [forall (p :: Pass).
OutputableBndrId p =>
[LConDeclField (GhcPass p)] -> SDoc
pprConDeclFields (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) [LConDeclField (GhcPass p)]
fields) forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
arrow]
ppr_arr :: HsArrow (GhcPass pass) -> SDoc
ppr_arr (HsLinearArrow HsLinearArrowTokens (GhcPass pass)
_) = forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocLinearTypes forall a b. (a -> b) -> a -> b
$ \Bool
show_linear_types ->
if Bool
show_linear_types then SDoc
lollipop else SDoc
arrow
ppr_arr HsArrow (GhcPass pass)
arr = forall (pass :: Pass).
OutputableBndrId pass =>
HsArrow (GhcPass pass) -> SDoc
pprHsArrow HsArrow (GhcPass pass)
arr
ppr_con_names :: (OutputableBndr a) => [GenLocated l a] -> SDoc
ppr_con_names :: forall a l. OutputableBndr a => [GenLocated l a] -> SDoc
ppr_con_names = forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc)
type instance XCFamEqn (GhcPass _) r = EpAnn [AddEpAnn]
type instance XXFamEqn (GhcPass _) r = DataConCantHappen
type instance Anno (FamEqn (GhcPass p) _) = SrcSpanAnnA
type instance XCClsInstDecl GhcPs = (EpAnn [AddEpAnn], AnnSortKey)
type instance XCClsInstDecl GhcRn = NoExtField
type instance XCClsInstDecl GhcTc = NoExtField
type instance XXClsInstDecl (GhcPass _) = DataConCantHappen
type instance XClsInstD (GhcPass _) = NoExtField
type instance XDataFamInstD (GhcPass _) = NoExtField
type instance XTyFamInstD GhcPs = NoExtField
type instance XTyFamInstD GhcRn = NoExtField
type instance XTyFamInstD GhcTc = NoExtField
type instance XXInstDecl (GhcPass _) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (TyFamInstDecl (GhcPass p)) where
ppr :: TyFamInstDecl (GhcPass p) -> SDoc
ppr = forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
pprTyFamInstDecl TopLevelFlag
TopLevel
pprTyFamInstDecl :: (OutputableBndrId p)
=> TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
pprTyFamInstDecl :: forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
pprTyFamInstDecl TopLevelFlag
top_lvl (TyFamInstDecl { tfid_eqn :: forall pass. TyFamInstDecl pass -> TyFamInstEqn pass
tfid_eqn = TyFamInstEqn (GhcPass p)
eqn })
= forall doc. IsLine doc => String -> doc
text String
"type" forall doc. IsLine doc => doc -> doc -> doc
<+> TopLevelFlag -> SDoc
ppr_instance_keyword TopLevelFlag
top_lvl forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
TyFamInstEqn (GhcPass p) -> SDoc
ppr_fam_inst_eqn TyFamInstEqn (GhcPass p)
eqn
ppr_instance_keyword :: TopLevelFlag -> SDoc
ppr_instance_keyword :: TopLevelFlag -> SDoc
ppr_instance_keyword TopLevelFlag
TopLevel = forall doc. IsLine doc => String -> doc
text String
"instance"
ppr_instance_keyword TopLevelFlag
NotTopLevel = forall doc. IsOutput doc => doc
empty
pprTyFamDefltDecl :: (OutputableBndrId p)
=> TyFamDefltDecl (GhcPass p) -> SDoc
pprTyFamDefltDecl :: forall (p :: Pass).
OutputableBndrId p =>
TyFamDefltDecl (GhcPass p) -> SDoc
pprTyFamDefltDecl = forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
pprTyFamInstDecl TopLevelFlag
NotTopLevel
ppr_fam_inst_eqn :: (OutputableBndrId p)
=> TyFamInstEqn (GhcPass p) -> SDoc
ppr_fam_inst_eqn :: forall (p :: Pass).
OutputableBndrId p =>
TyFamInstEqn (GhcPass p) -> SDoc
ppr_fam_inst_eqn (FamEqn { feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_tycon = L Anno (IdGhcP p)
_ IdGhcP p
tycon
, feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> HsOuterFamEqnTyVarBndrs pass
feqn_bndrs = HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs
, feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_pats = HsTyPats (GhcPass p)
pats
, feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_fixity = LexicalFixity
fixity
, feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs = LHsType (GhcPass p)
rhs })
= forall (p :: Pass).
OutputableBndrId p =>
IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsTyPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pprHsFamInstLHS IdGhcP p
tycon HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs HsTyPats (GhcPass p)
pats LexicalFixity
fixity forall a. Maybe a
Nothing forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => doc
equals forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
rhs
instance OutputableBndrId p
=> Outputable (DataFamInstDecl (GhcPass p)) where
ppr :: DataFamInstDecl (GhcPass p) -> SDoc
ppr = forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> DataFamInstDecl (GhcPass p) -> SDoc
pprDataFamInstDecl TopLevelFlag
TopLevel
pprDataFamInstDecl :: (OutputableBndrId p)
=> TopLevelFlag -> DataFamInstDecl (GhcPass p) -> SDoc
pprDataFamInstDecl :: forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> DataFamInstDecl (GhcPass p) -> SDoc
pprDataFamInstDecl TopLevelFlag
top_lvl (DataFamInstDecl { dfid_eqn :: forall pass. DataFamInstDecl pass -> FamEqn pass (HsDataDefn pass)
dfid_eqn =
(FamEqn { feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_tycon = L Anno (IdGhcP p)
_ IdGhcP p
tycon
, feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> HsOuterFamEqnTyVarBndrs pass
feqn_bndrs = HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs
, feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_pats = HsTyPats (GhcPass p)
pats
, feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_fixity = LexicalFixity
fixity
, feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs = HsDataDefn (GhcPass p)
defn })})
= forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
pp_data_defn Maybe
(GenLocated
SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
-> SDoc
pp_hdr HsDataDefn (GhcPass p)
defn
where
pp_hdr :: Maybe
(GenLocated
SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
-> SDoc
pp_hdr Maybe
(GenLocated
SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
mctxt = TopLevelFlag -> SDoc
ppr_instance_keyword TopLevelFlag
top_lvl
forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsTyPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pprHsFamInstLHS IdGhcP p
tycon HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs HsTyPats (GhcPass p)
pats LexicalFixity
fixity Maybe
(GenLocated
SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
mctxt
pprDataFamInstFlavour :: DataFamInstDecl (GhcPass p) -> SDoc
pprDataFamInstFlavour :: forall (p :: Pass). DataFamInstDecl (GhcPass p) -> SDoc
pprDataFamInstFlavour DataFamInstDecl
{ dfid_eqn :: forall pass. DataFamInstDecl pass -> FamEqn pass (HsDataDefn pass)
dfid_eqn = FamEqn { feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs = HsDataDefn { dd_cons :: forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons = DataDefnCons (LConDecl (GhcPass p))
cons }}}
= forall a. Outputable a => a -> SDoc
ppr (forall a. DataDefnCons a -> NewOrData
dataDefnConsNewOrData DataDefnCons (LConDecl (GhcPass p))
cons)
pprHsFamInstLHS :: (OutputableBndrId p)
=> IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsTyPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pprHsFamInstLHS :: forall (p :: Pass).
OutputableBndrId p =>
IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsTyPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pprHsFamInstLHS IdP (GhcPass p)
thing HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs HsTyPats (GhcPass p)
typats LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
mb_ctxt
= forall doc. IsLine doc => [doc] -> doc
hsep [ forall (p :: Pass).
OutputableBndrId p =>
HsOuterFamEqnTyVarBndrs (GhcPass p) -> SDoc
pprHsOuterFamEqnTyVarBndrs HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs
, forall (p :: Pass).
OutputableBndrId p =>
Maybe (LHsContext (GhcPass p)) -> SDoc
pprLHsContext Maybe (LHsContext (GhcPass p))
mb_ctxt
, forall id tm ty.
(OutputableBndr id, Outputable tm, Outputable ty) =>
id -> LexicalFixity -> [HsArg tm ty] -> SDoc
pprHsArgsApp IdP (GhcPass p)
thing LexicalFixity
fixity HsTyPats (GhcPass p)
typats ]
instance OutputableBndrId p
=> Outputable (ClsInstDecl (GhcPass p)) where
ppr :: ClsInstDecl (GhcPass p) -> SDoc
ppr (ClsInstDecl { cid_poly_ty :: forall pass. ClsInstDecl pass -> LHsSigType pass
cid_poly_ty = LHsSigType (GhcPass p)
inst_ty, cid_binds :: forall pass. ClsInstDecl pass -> LHsBinds pass
cid_binds = LHsBinds (GhcPass p)
binds
, cid_sigs :: forall pass. ClsInstDecl pass -> [LSig pass]
cid_sigs = [LSig (GhcPass p)]
sigs, cid_tyfam_insts :: forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_tyfam_insts = [LTyFamInstDecl (GhcPass p)]
ats
, cid_overlap_mode :: forall pass. ClsInstDecl pass -> Maybe (XRec pass OverlapMode)
cid_overlap_mode = Maybe (XRec (GhcPass p) OverlapMode)
mbOverlap
, cid_datafam_insts :: forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts = [LDataFamInstDecl (GhcPass p)]
adts })
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LSig (GhcPass p)]
sigs, forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LTyFamInstDecl (GhcPass p)]
ats, forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LDataFamInstDecl (GhcPass p)]
adts, forall a. Bag a -> Bool
isEmptyBag LHsBinds (GhcPass p)
binds
= SDoc
top_matter
| Bool
otherwise
= forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
top_matter forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"where"
, Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
pprDeclList forall a b. (a -> b) -> a -> b
$
forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
pprTyFamInstDecl TopLevelFlag
NotTopLevel forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LTyFamInstDecl (GhcPass p)]
ats forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> DataFamInstDecl (GhcPass p) -> SDoc
pprDataFamInstDecl TopLevelFlag
NotTopLevel forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LDataFamInstDecl (GhcPass p)]
adts forall a. [a] -> [a] -> [a]
++
forall (idL :: Pass) (idR :: Pass) (id2 :: Pass).
(OutputableBndrId idL, OutputableBndrId idR,
OutputableBndrId id2) =>
LHsBindsLR (GhcPass idL) (GhcPass idR)
-> [LSig (GhcPass id2)] -> [SDoc]
pprLHsBindsForUser LHsBinds (GhcPass p)
binds [LSig (GhcPass p)]
sigs ]
where
top_matter :: SDoc
top_matter = forall doc. IsLine doc => String -> doc
text String
"instance" forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe (LocatedP OverlapMode) -> SDoc
ppOverlapPragma Maybe (XRec (GhcPass p) OverlapMode)
mbOverlap
forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
inst_ty
ppDerivStrategy :: OutputableBndrId p
=> Maybe (LDerivStrategy (GhcPass p)) -> SDoc
ppDerivStrategy :: forall (p :: Pass).
OutputableBndrId p =>
Maybe (LDerivStrategy (GhcPass p)) -> SDoc
ppDerivStrategy Maybe (LDerivStrategy (GhcPass p))
mb =
case Maybe (LDerivStrategy (GhcPass p))
mb of
Maybe (LDerivStrategy (GhcPass p))
Nothing -> forall doc. IsOutput doc => doc
empty
Just (L SrcAnn NoEpAnns
_ DerivStrategy (GhcPass p)
ds) -> forall a. Outputable a => a -> SDoc
ppr DerivStrategy (GhcPass p)
ds
ppOverlapPragma :: Maybe (LocatedP OverlapMode) -> SDoc
ppOverlapPragma :: Maybe (LocatedP OverlapMode) -> SDoc
ppOverlapPragma Maybe (LocatedP OverlapMode)
mb =
case Maybe (LocatedP OverlapMode)
mb of
Maybe (LocatedP OverlapMode)
Nothing -> forall doc. IsOutput doc => doc
empty
Just (L SrcSpanAnnP
_ (NoOverlap SourceText
s)) -> forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# NO_OVERLAP #-}"
Just (L SrcSpanAnnP
_ (Overlappable SourceText
s)) -> forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# OVERLAPPABLE #-}"
Just (L SrcSpanAnnP
_ (Overlapping SourceText
s)) -> forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# OVERLAPPING #-}"
Just (L SrcSpanAnnP
_ (Overlaps SourceText
s)) -> forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# OVERLAPS #-}"
Just (L SrcSpanAnnP
_ (Incoherent SourceText
s)) -> forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# INCOHERENT #-}"
where
maybe_stext :: SourceText -> String -> doc
maybe_stext SourceText
NoSourceText String
alt = forall doc. IsLine doc => String -> doc
text String
alt
maybe_stext (SourceText String
src) String
_ = forall doc. IsLine doc => String -> doc
text String
src forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
instance (OutputableBndrId p) => Outputable (InstDecl (GhcPass p)) where
ppr :: InstDecl (GhcPass p) -> SDoc
ppr (ClsInstD { cid_inst :: forall pass. InstDecl pass -> ClsInstDecl pass
cid_inst = ClsInstDecl (GhcPass p)
decl }) = forall a. Outputable a => a -> SDoc
ppr ClsInstDecl (GhcPass p)
decl
ppr (TyFamInstD { tfid_inst :: forall pass. InstDecl pass -> TyFamInstDecl pass
tfid_inst = TyFamInstDecl (GhcPass p)
decl }) = forall a. Outputable a => a -> SDoc
ppr TyFamInstDecl (GhcPass p)
decl
ppr (DataFamInstD { dfid_inst :: forall pass. InstDecl pass -> DataFamInstDecl pass
dfid_inst = DataFamInstDecl (GhcPass p)
decl }) = forall a. Outputable a => a -> SDoc
ppr DataFamInstDecl (GhcPass p)
decl
instDeclDataFamInsts :: [LInstDecl (GhcPass p)] -> [DataFamInstDecl (GhcPass p)]
instDeclDataFamInsts :: forall (p :: Pass).
[LInstDecl (GhcPass p)] -> [DataFamInstDecl (GhcPass p)]
instDeclDataFamInsts [LInstDecl (GhcPass p)]
inst_decls
= forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall (p :: Pass).
LInstDecl (GhcPass p) -> [DataFamInstDecl (GhcPass p)]
do_one [LInstDecl (GhcPass p)]
inst_decls
where
do_one :: LInstDecl (GhcPass p) -> [DataFamInstDecl (GhcPass p)]
do_one :: forall (p :: Pass).
LInstDecl (GhcPass p) -> [DataFamInstDecl (GhcPass p)]
do_one (L SrcSpanAnnA
_ (ClsInstD { cid_inst :: forall pass. InstDecl pass -> ClsInstDecl pass
cid_inst = ClsInstDecl { cid_datafam_insts :: forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts = [LDataFamInstDecl (GhcPass p)]
fam_insts } }))
= forall a b. (a -> b) -> [a] -> [b]
map forall l e. GenLocated l e -> e
unLoc [LDataFamInstDecl (GhcPass p)]
fam_insts
do_one (L SrcSpanAnnA
_ (DataFamInstD { dfid_inst :: forall pass. InstDecl pass -> DataFamInstDecl pass
dfid_inst = DataFamInstDecl (GhcPass p)
fam_inst })) = [DataFamInstDecl (GhcPass p)
fam_inst]
do_one (L SrcSpanAnnA
_ (TyFamInstD {})) = []
newOrDataToFlavour :: NewOrData -> TyConFlavour
newOrDataToFlavour :: NewOrData -> TyConFlavour
newOrDataToFlavour NewOrData
NewType = TyConFlavour
NewtypeFlavour
newOrDataToFlavour NewOrData
DataType = TyConFlavour
DataTypeFlavour
instance Outputable NewOrData where
ppr :: NewOrData -> SDoc
ppr NewOrData
NewType = forall doc. IsLine doc => String -> doc
text String
"newtype"
ppr NewOrData
DataType = forall doc. IsLine doc => String -> doc
text String
"data"
anyLConIsGadt :: Foldable f => f (GenLocated l (ConDecl pass)) -> Bool
anyLConIsGadt :: forall (f :: * -> *) l pass.
Foldable f =>
f (GenLocated l (ConDecl pass)) -> Bool
anyLConIsGadt f (GenLocated l (ConDecl pass))
xs = case forall (t :: * -> *) a. Foldable t => t a -> [a]
toList f (GenLocated l (ConDecl pass))
xs of
L l
_ ConDeclGADT {} : [GenLocated l (ConDecl pass)]
_ -> Bool
True
[GenLocated l (ConDecl pass)]
_ -> Bool
False
{-# SPECIALIZE anyLConIsGadt :: [GenLocated l (ConDecl pass)] -> Bool #-}
{-# SPECIALIZE anyLConIsGadt :: DataDefnCons (GenLocated l (ConDecl pass)) -> Bool #-}
type instance XCDerivDecl (GhcPass _) = EpAnn [AddEpAnn]
type instance XXDerivDecl (GhcPass _) = DataConCantHappen
type instance Anno OverlapMode = SrcSpanAnnP
instance OutputableBndrId p
=> Outputable (DerivDecl (GhcPass p)) where
ppr :: DerivDecl (GhcPass p) -> SDoc
ppr (DerivDecl { deriv_type :: forall pass. DerivDecl pass -> LHsSigWcType pass
deriv_type = LHsSigWcType (GhcPass p)
ty
, deriv_strategy :: forall pass. DerivDecl pass -> Maybe (LDerivStrategy pass)
deriv_strategy = Maybe (LDerivStrategy (GhcPass p))
ds
, deriv_overlap_mode :: forall pass. DerivDecl pass -> Maybe (XRec pass OverlapMode)
deriv_overlap_mode = Maybe (XRec (GhcPass p) OverlapMode)
o })
= forall doc. IsLine doc => [doc] -> doc
hsep [ forall doc. IsLine doc => String -> doc
text String
"deriving"
, forall (p :: Pass).
OutputableBndrId p =>
Maybe (LDerivStrategy (GhcPass p)) -> SDoc
ppDerivStrategy Maybe (LDerivStrategy (GhcPass p))
ds
, forall doc. IsLine doc => String -> doc
text String
"instance"
, Maybe (LocatedP OverlapMode) -> SDoc
ppOverlapPragma Maybe (XRec (GhcPass p) OverlapMode)
o
, forall a. Outputable a => a -> SDoc
ppr LHsSigWcType (GhcPass p)
ty ]
type instance XStockStrategy GhcPs = EpAnn [AddEpAnn]
type instance XStockStrategy GhcRn = NoExtField
type instance XStockStrategy GhcTc = NoExtField
type instance XAnyClassStrategy GhcPs = EpAnn [AddEpAnn]
type instance XAnyClassStrategy GhcRn = NoExtField
type instance XAnyClassStrategy GhcTc = NoExtField
type instance XNewtypeStrategy GhcPs = EpAnn [AddEpAnn]
type instance XNewtypeStrategy GhcRn = NoExtField
type instance XNewtypeStrategy GhcTc = NoExtField
type instance XViaStrategy GhcPs = XViaStrategyPs
type instance XViaStrategy GhcRn = LHsSigType GhcRn
type instance XViaStrategy GhcTc = Type
data XViaStrategyPs = XViaStrategyPs (EpAnn [AddEpAnn]) (LHsSigType GhcPs)
instance OutputableBndrId p
=> Outputable (DerivStrategy (GhcPass p)) where
ppr :: DerivStrategy (GhcPass p) -> SDoc
ppr (StockStrategy XStockStrategy (GhcPass p)
_) = forall doc. IsLine doc => String -> doc
text String
"stock"
ppr (AnyclassStrategy XAnyClassStrategy (GhcPass p)
_) = forall doc. IsLine doc => String -> doc
text String
"anyclass"
ppr (NewtypeStrategy XNewtypeStrategy (GhcPass p)
_) = forall doc. IsLine doc => String -> doc
text String
"newtype"
ppr (ViaStrategy XViaStrategy (GhcPass p)
ty) = forall doc. IsLine doc => String -> doc
text String
"via" forall doc. IsLine doc => doc -> doc -> doc
<+> case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs -> forall a. Outputable a => a -> SDoc
ppr XViaStrategy (GhcPass p)
ty
GhcPass p
GhcRn -> forall a. Outputable a => a -> SDoc
ppr XViaStrategy (GhcPass p)
ty
GhcPass p
GhcTc -> forall a. Outputable a => a -> SDoc
ppr XViaStrategy (GhcPass p)
ty
instance Outputable XViaStrategyPs where
ppr :: XViaStrategyPs -> SDoc
ppr (XViaStrategyPs EpAnn [AddEpAnn]
_ LHsSigType GhcPs
t) = forall a. Outputable a => a -> SDoc
ppr LHsSigType GhcPs
t
foldDerivStrategy :: (p ~ GhcPass pass)
=> r -> (XViaStrategy p -> r) -> DerivStrategy p -> r
foldDerivStrategy :: forall p (pass :: Pass) r.
(p ~ GhcPass pass) =>
r -> (XViaStrategy p -> r) -> DerivStrategy p -> r
foldDerivStrategy r
other XViaStrategy p -> r
_ (StockStrategy XStockStrategy p
_) = r
other
foldDerivStrategy r
other XViaStrategy p -> r
_ (AnyclassStrategy XAnyClassStrategy p
_) = r
other
foldDerivStrategy r
other XViaStrategy p -> r
_ (NewtypeStrategy XNewtypeStrategy p
_) = r
other
foldDerivStrategy r
_ XViaStrategy p -> r
via (ViaStrategy XViaStrategy p
t) = XViaStrategy p -> r
via XViaStrategy p
t
mapDerivStrategy :: (p ~ GhcPass pass)
=> (XViaStrategy p -> XViaStrategy p)
-> DerivStrategy p -> DerivStrategy p
mapDerivStrategy :: forall p (pass :: Pass).
(p ~ GhcPass pass) =>
(XViaStrategy p -> XViaStrategy p)
-> DerivStrategy p -> DerivStrategy p
mapDerivStrategy XViaStrategy p -> XViaStrategy p
f DerivStrategy p
ds = forall p (pass :: Pass) r.
(p ~ GhcPass pass) =>
r -> (XViaStrategy p -> r) -> DerivStrategy p -> r
foldDerivStrategy DerivStrategy p
ds (forall pass. XViaStrategy pass -> DerivStrategy pass
ViaStrategy forall b c a. (b -> c) -> (a -> b) -> a -> c
. XViaStrategy p -> XViaStrategy p
f) DerivStrategy p
ds
type instance XCDefaultDecl GhcPs = EpAnn [AddEpAnn]
type instance XCDefaultDecl GhcRn = NoExtField
type instance XCDefaultDecl GhcTc = NoExtField
type instance XXDefaultDecl (GhcPass _) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (DefaultDecl (GhcPass p)) where
ppr :: DefaultDecl (GhcPass p) -> SDoc
ppr (DefaultDecl XCDefaultDecl (GhcPass p)
_ [LHsType (GhcPass p)]
tys)
= forall doc. IsLine doc => String -> doc
text String
"default" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => doc -> doc
parens (forall a. Outputable a => [a] -> SDoc
interpp'SP [LHsType (GhcPass p)]
tys)
type instance XForeignImport GhcPs = EpAnn [AddEpAnn]
type instance XForeignImport GhcRn = NoExtField
type instance XForeignImport GhcTc = Coercion
type instance XForeignExport GhcPs = EpAnn [AddEpAnn]
type instance XForeignExport GhcRn = NoExtField
type instance XForeignExport GhcTc = Coercion
type instance XXForeignDecl (GhcPass _) = DataConCantHappen
type instance XCImport (GhcPass _) = Located SourceText
type instance XXForeignImport (GhcPass _) = DataConCantHappen
type instance XCExport (GhcPass _) = Located SourceText
type instance XXForeignExport (GhcPass _) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (ForeignDecl (GhcPass p)) where
ppr :: ForeignDecl (GhcPass p) -> SDoc
ppr (ForeignImport { fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_name = LIdP (GhcPass p)
n, fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_sig_ty = LHsSigType (GhcPass p)
ty, fd_fi :: forall pass. ForeignDecl pass -> ForeignImport pass
fd_fi = ForeignImport (GhcPass p)
fimport })
= SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"foreign import" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr ForeignImport (GhcPass p)
fimport forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
n)
Int
2 (SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
ty)
ppr (ForeignExport { fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_name = LIdP (GhcPass p)
n, fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_sig_ty = LHsSigType (GhcPass p)
ty, fd_fe :: forall pass. ForeignDecl pass -> ForeignExport pass
fd_fe = ForeignExport (GhcPass p)
fexport }) =
SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"foreign export" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr ForeignExport (GhcPass p)
fexport forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
n)
Int
2 (SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
ty)
instance OutputableBndrId p
=> Outputable (ForeignImport (GhcPass p)) where
ppr :: ForeignImport (GhcPass p) -> SDoc
ppr (CImport (L SrcSpan
_ SourceText
srcText) XRec (GhcPass p) CCallConv
cconv XRec (GhcPass p) Safety
safety Maybe Header
mHeader CImportSpec
spec) =
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) CCallConv
cconv forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) Safety
safety
forall doc. IsLine doc => doc -> doc -> doc
<+> SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
srcText (CImportSpec -> String -> SDoc
pprCEntity CImportSpec
spec String
"")
where
pp_hdr :: SDoc
pp_hdr = case Maybe Header
mHeader of
Maybe Header
Nothing -> forall doc. IsOutput doc => doc
empty
Just (Header SourceText
_ CLabelString
header) -> forall doc. IsLine doc => CLabelString -> doc
ftext CLabelString
header
pprCEntity :: CImportSpec -> String -> SDoc
pprCEntity (CLabel CLabelString
lbl) String
_ =
forall doc. IsLine doc => doc -> doc
doubleQuotes forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"static" forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_hdr forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
'&' forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr CLabelString
lbl
pprCEntity (CFunction (StaticTarget SourceText
st CLabelString
_lbl Maybe Unit
_ Bool
isFun)) String
src =
if Bool
dqNeeded then forall doc. IsLine doc => doc -> doc
doubleQuotes SDoc
ce else forall doc. IsOutput doc => doc
empty
where
dqNeeded :: Bool
dqNeeded = (forall a. Int -> [a] -> [a]
take Int
6 String
src forall a. Eq a => a -> a -> Bool
== String
"static")
Bool -> Bool -> Bool
|| forall a. Maybe a -> Bool
isJust Maybe Header
mHeader
Bool -> Bool -> Bool
|| Bool -> Bool
not Bool
isFun
Bool -> Bool -> Bool
|| SourceText
st forall a. Eq a => a -> a -> Bool
/= SourceText
NoSourceText
ce :: SDoc
ce =
(if forall a. Int -> [a] -> [a]
take Int
6 String
src forall a. Eq a => a -> a -> Bool
== String
"static" then forall doc. IsLine doc => String -> doc
text String
"static" else forall doc. IsOutput doc => doc
empty)
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_hdr
forall doc. IsLine doc => doc -> doc -> doc
<+> (if Bool
isFun then forall doc. IsOutput doc => doc
empty else forall doc. IsLine doc => String -> doc
text String
"value")
forall doc. IsLine doc => doc -> doc -> doc
<+> (SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st forall doc. IsOutput doc => doc
empty)
pprCEntity (CFunction CCallTarget
DynamicTarget) String
_ =
forall doc. IsLine doc => doc -> doc
doubleQuotes forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"dynamic"
pprCEntity CImportSpec
CWrapper String
_ = forall doc. IsLine doc => doc -> doc
doubleQuotes forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"wrapper"
instance OutputableBndrId p
=> Outputable (ForeignExport (GhcPass p)) where
ppr :: ForeignExport (GhcPass p) -> SDoc
ppr (CExport XCExport (GhcPass p)
_ (L SrcSpan
_ (CExportStatic SourceText
_ CLabelString
lbl CCallConv
cconv))) =
forall a. Outputable a => a -> SDoc
ppr CCallConv
cconv forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
'"' forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr CLabelString
lbl forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
'"'
type instance XCRuleDecls GhcPs = (EpAnn [AddEpAnn], SourceText)
type instance XCRuleDecls GhcRn = SourceText
type instance XCRuleDecls GhcTc = SourceText
type instance XXRuleDecls (GhcPass _) = DataConCantHappen
type instance XHsRule GhcPs = (EpAnn HsRuleAnn, SourceText)
type instance XHsRule GhcRn = (HsRuleRn, SourceText)
type instance XHsRule GhcTc = (HsRuleRn, SourceText)
data HsRuleRn = HsRuleRn NameSet NameSet
deriving Typeable HsRuleRn
HsRuleRn -> DataType
HsRuleRn -> Constr
(forall b. Data b => b -> b) -> HsRuleRn -> HsRuleRn
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) -> HsRuleRn -> u
forall u. (forall d. Data d => d -> u) -> HsRuleRn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleRn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleRn -> c HsRuleRn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleRn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleRn)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleRn -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleRn -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleRn -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleRn -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
gmapT :: (forall b. Data b => b -> b) -> HsRuleRn -> HsRuleRn
$cgmapT :: (forall b. Data b => b -> b) -> HsRuleRn -> HsRuleRn
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleRn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleRn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleRn)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleRn)
dataTypeOf :: HsRuleRn -> DataType
$cdataTypeOf :: HsRuleRn -> DataType
toConstr :: HsRuleRn -> Constr
$ctoConstr :: HsRuleRn -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleRn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleRn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleRn -> c HsRuleRn
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleRn -> c HsRuleRn
Data
type instance XXRuleDecl (GhcPass _) = DataConCantHappen
data HsRuleAnn
= HsRuleAnn
{ HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn)
ra_tyanns :: Maybe (AddEpAnn, AddEpAnn)
, HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn)
ra_tmanns :: Maybe (AddEpAnn, AddEpAnn)
, HsRuleAnn -> [AddEpAnn]
ra_rest :: [AddEpAnn]
} deriving (Typeable HsRuleAnn
HsRuleAnn -> DataType
HsRuleAnn -> Constr
(forall b. Data b => b -> b) -> HsRuleAnn -> HsRuleAnn
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) -> HsRuleAnn -> u
forall u. (forall d. Data d => d -> u) -> HsRuleAnn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleAnn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleAnn -> c HsRuleAnn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleAnn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleAnn)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleAnn -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleAnn -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleAnn -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleAnn -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
gmapT :: (forall b. Data b => b -> b) -> HsRuleAnn -> HsRuleAnn
$cgmapT :: (forall b. Data b => b -> b) -> HsRuleAnn -> HsRuleAnn
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleAnn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleAnn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleAnn)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleAnn)
dataTypeOf :: HsRuleAnn -> DataType
$cdataTypeOf :: HsRuleAnn -> DataType
toConstr :: HsRuleAnn -> Constr
$ctoConstr :: HsRuleAnn -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleAnn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleAnn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleAnn -> c HsRuleAnn
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleAnn -> c HsRuleAnn
Data, HsRuleAnn -> HsRuleAnn -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HsRuleAnn -> HsRuleAnn -> Bool
$c/= :: HsRuleAnn -> HsRuleAnn -> Bool
== :: HsRuleAnn -> HsRuleAnn -> Bool
$c== :: HsRuleAnn -> HsRuleAnn -> Bool
Eq)
flattenRuleDecls :: [LRuleDecls (GhcPass p)] -> [LRuleDecl (GhcPass p)]
flattenRuleDecls :: forall (p :: Pass).
[LRuleDecls (GhcPass p)] -> [LRuleDecl (GhcPass p)]
flattenRuleDecls [LRuleDecls (GhcPass p)]
decls = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall pass. RuleDecls pass -> [LRuleDecl pass]
rds_rules forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [LRuleDecls (GhcPass p)]
decls
type instance XCRuleBndr (GhcPass _) = EpAnn [AddEpAnn]
type instance XRuleBndrSig (GhcPass _) = EpAnn [AddEpAnn]
type instance XXRuleBndr (GhcPass _) = DataConCantHappen
instance (OutputableBndrId p) => Outputable (RuleDecls (GhcPass p)) where
ppr :: RuleDecls (GhcPass p) -> SDoc
ppr (HsRules { rds_ext :: forall pass. RuleDecls pass -> XCRuleDecls pass
rds_ext = XCRuleDecls (GhcPass p)
ext
, rds_rules :: forall pass. RuleDecls pass -> [LRuleDecl pass]
rds_rules = [LRuleDecl (GhcPass p)]
rules })
= SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st (forall doc. IsLine doc => String -> doc
text String
"{-# RULES")
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsDoc doc => [doc] -> doc
vcat (forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
semi (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LRuleDecl (GhcPass p)]
rules)) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
where st :: SourceText
st = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs | (EpAnn [AddEpAnn]
_, SourceText
st) <- XCRuleDecls (GhcPass p)
ext -> SourceText
st
GhcPass p
GhcRn -> XCRuleDecls (GhcPass p)
ext
GhcPass p
GhcTc -> XCRuleDecls (GhcPass p)
ext
instance (OutputableBndrId p) => Outputable (RuleDecl (GhcPass p)) where
ppr :: RuleDecl (GhcPass p) -> SDoc
ppr (HsRule { rd_ext :: forall pass. RuleDecl pass -> XHsRule pass
rd_ext = XHsRule (GhcPass p)
ext
, rd_name :: forall pass. RuleDecl pass -> XRec pass CLabelString
rd_name = XRec (GhcPass p) CLabelString
name
, rd_act :: forall pass. RuleDecl pass -> Activation
rd_act = Activation
act
, rd_tyvs :: forall pass.
RuleDecl pass -> Maybe [LHsTyVarBndr () (NoGhcTc pass)]
rd_tyvs = Maybe [LHsTyVarBndr () (NoGhcTc (GhcPass p))]
tys
, rd_tmvs :: forall pass. RuleDecl pass -> [LRuleBndr pass]
rd_tmvs = [LRuleBndr (GhcPass p)]
tms
, rd_lhs :: forall pass. RuleDecl pass -> XRec pass (HsExpr pass)
rd_lhs = XRec (GhcPass p) (HsExpr (GhcPass p))
lhs
, rd_rhs :: forall pass. RuleDecl pass -> XRec pass (HsExpr pass)
rd_rhs = XRec (GhcPass p) (HsExpr (GhcPass p))
rhs })
= forall doc. IsLine doc => [doc] -> doc
sep [forall a. SourceText -> GenLocated a CLabelString -> SDoc
pprFullRuleName SourceText
st XRec (GhcPass p) CLabelString
name forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Activation
act,
Int -> SDoc -> SDoc
nest Int
4 (forall {a}. Outputable a => Maybe [a] -> SDoc
pp_forall_ty Maybe [LHsTyVarBndr () (NoGhcTc (GhcPass p))]
tys forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe
[GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
-> SDoc
pp_forall_tm Maybe [LHsTyVarBndr () (NoGhcTc (GhcPass p))]
tys
forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
lhs)),
Int -> SDoc -> SDoc
nest Int
6 (forall doc. IsLine doc => doc
equals forall doc. IsLine doc => doc -> doc -> doc
<+> forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
rhs)) ]
where
pp_forall_ty :: Maybe [a] -> SDoc
pp_forall_ty Maybe [a]
Nothing = forall doc. IsOutput doc => doc
empty
pp_forall_ty (Just [a]
qtvs) = SDoc
forAllLit forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
fsep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [a]
qtvs) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
dot
pp_forall_tm :: Maybe
[GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
-> SDoc
pp_forall_tm Maybe
[GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
Nothing | forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LRuleBndr (GhcPass p)]
tms = forall doc. IsOutput doc => doc
empty
pp_forall_tm Maybe
[GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
_ = SDoc
forAllLit forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
fsep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LRuleBndr (GhcPass p)]
tms) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
dot
st :: SourceText
st = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs | (EpAnn HsRuleAnn
_, SourceText
st) <- XHsRule (GhcPass p)
ext -> SourceText
st
GhcPass p
GhcRn | (HsRuleRn
_, SourceText
st) <- XHsRule (GhcPass p)
ext -> SourceText
st
GhcPass p
GhcTc | (HsRuleRn
_, SourceText
st) <- XHsRule (GhcPass p)
ext -> SourceText
st
instance (OutputableBndrId p) => Outputable (RuleBndr (GhcPass p)) where
ppr :: RuleBndr (GhcPass p) -> SDoc
ppr (RuleBndr XCRuleBndr (GhcPass p)
_ LIdP (GhcPass p)
name) = forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
name
ppr (RuleBndrSig XRuleBndrSig (GhcPass p)
_ LIdP (GhcPass p)
name HsPatSigType (GhcPass p)
ty) = forall doc. IsLine doc => doc -> doc
parens (forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
name forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr HsPatSigType (GhcPass p)
ty)
pprFullRuleName :: SourceText -> GenLocated a (RuleName) -> SDoc
pprFullRuleName :: forall a. SourceText -> GenLocated a CLabelString -> SDoc
pprFullRuleName SourceText
st (L a
_ CLabelString
n) = SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st (forall doc. IsLine doc => doc -> doc
doubleQuotes forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => CLabelString -> doc
ftext CLabelString
n)
type instance XWarnings GhcPs = (EpAnn [AddEpAnn], SourceText)
type instance XWarnings GhcRn = SourceText
type instance XWarnings GhcTc = SourceText
type instance XXWarnDecls (GhcPass _) = DataConCantHappen
type instance XWarning (GhcPass _) = EpAnn [AddEpAnn]
type instance XXWarnDecl (GhcPass _) = DataConCantHappen
instance OutputableBndrId p
=> Outputable (WarnDecls (GhcPass p)) where
ppr :: WarnDecls (GhcPass p) -> SDoc
ppr (Warnings XWarnings (GhcPass p)
ext [LWarnDecl (GhcPass p)]
decls)
= forall doc. IsLine doc => String -> doc
text String
src forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsDoc doc => [doc] -> doc
vcat (forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LWarnDecl (GhcPass p)]
decls)) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"#-}"
where src :: String
src = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
GhcPass p
GhcPs | (EpAnn [AddEpAnn]
_, SourceText String
src) <- XWarnings (GhcPass p)
ext -> String
src
GhcPass p
GhcRn | SourceText String
src <- XWarnings (GhcPass p)
ext -> String
src
GhcPass p
GhcTc | SourceText String
src <- XWarnings (GhcPass p)
ext -> String
src
GhcPass p
_ -> forall a. HasCallStack => String -> a
panic String
"WarnDecls"
instance OutputableBndrId p
=> Outputable (WarnDecl (GhcPass p)) where
ppr :: WarnDecl (GhcPass p) -> SDoc
ppr (Warning XWarning (GhcPass p)
_ [LIdP (GhcPass p)]
thing WarningTxt (GhcPass p)
txt)
= forall doc. IsLine doc => [doc] -> doc
hsep ( forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [LIdP (GhcPass p)]
thing))
forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr WarningTxt (GhcPass p)
txt
type instance XHsAnnotation (GhcPass _) = (EpAnn AnnPragma, SourceText)
type instance XXAnnDecl (GhcPass _) = DataConCantHappen
instance (OutputableBndrId p) => Outputable (AnnDecl (GhcPass p)) where
ppr :: AnnDecl (GhcPass p) -> SDoc
ppr (HsAnnotation XHsAnnotation (GhcPass p)
_ AnnProvenance (GhcPass p)
provenance XRec (GhcPass p) (HsExpr (GhcPass p))
expr)
= forall doc. IsLine doc => [doc] -> doc
hsep [forall doc. IsLine doc => String -> doc
text String
"{-#", forall (p :: Pass).
OutputableBndrId p =>
AnnProvenance (GhcPass p) -> SDoc
pprAnnProvenance AnnProvenance (GhcPass p)
provenance, forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
expr), forall doc. IsLine doc => String -> doc
text String
"#-}"]
pprAnnProvenance :: OutputableBndrId p => AnnProvenance (GhcPass p) -> SDoc
pprAnnProvenance :: forall (p :: Pass).
OutputableBndrId p =>
AnnProvenance (GhcPass p) -> SDoc
pprAnnProvenance AnnProvenance (GhcPass p)
ModuleAnnProvenance = forall doc. IsLine doc => String -> doc
text String
"ANN module"
pprAnnProvenance (ValueAnnProvenance (L Anno (IdGhcP p)
_ IdGhcP p
name))
= forall doc. IsLine doc => String -> doc
text String
"ANN" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr IdGhcP p
name
pprAnnProvenance (TypeAnnProvenance (L Anno (IdGhcP p)
_ IdGhcP p
name))
= forall doc. IsLine doc => String -> doc
text String
"ANN type" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr IdGhcP p
name
type instance XCRoleAnnotDecl GhcPs = EpAnn [AddEpAnn]
type instance XCRoleAnnotDecl GhcRn = NoExtField
type instance XCRoleAnnotDecl GhcTc = NoExtField
type instance XXRoleAnnotDecl (GhcPass _) = DataConCantHappen
type instance Anno (Maybe Role) = SrcAnn NoEpAnns
instance OutputableBndr (IdP (GhcPass p))
=> Outputable (RoleAnnotDecl (GhcPass p)) where
ppr :: RoleAnnotDecl (GhcPass p) -> SDoc
ppr (RoleAnnotDecl XCRoleAnnotDecl (GhcPass p)
_ LIdP (GhcPass p)
ltycon [XRec (GhcPass p) (Maybe Role)]
roles)
= forall doc. IsLine doc => String -> doc
text String
"type role" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
ltycon) forall doc. IsLine doc => doc -> doc -> doc
<+>
forall doc. IsLine doc => [doc] -> doc
hsep (forall a b. (a -> b) -> [a] -> [b]
map (forall {a}. Outputable a => Maybe a -> SDoc
pp_role forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall l e. GenLocated l e -> e
unLoc) [XRec (GhcPass p) (Maybe Role)]
roles)
where
pp_role :: Maybe a -> SDoc
pp_role Maybe a
Nothing = forall doc. IsLine doc => doc
underscore
pp_role (Just a
r) = forall a. Outputable a => a -> SDoc
ppr a
r
roleAnnotDeclName :: RoleAnnotDecl (GhcPass p) -> IdP (GhcPass p)
roleAnnotDeclName :: forall (p :: Pass). RoleAnnotDecl (GhcPass p) -> IdP (GhcPass p)
roleAnnotDeclName (RoleAnnotDecl XCRoleAnnotDecl (GhcPass p)
_ (L Anno (IdGhcP p)
_ IdGhcP p
name) [XRec (GhcPass p) (Maybe Role)]
_) = IdGhcP p
name
type instance Anno (HsDecl (GhcPass _)) = SrcSpanAnnA
type instance Anno (SpliceDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (TyClDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (FunDep (GhcPass p)) = SrcSpanAnnA
type instance Anno (FamilyResultSig (GhcPass p)) = SrcAnn NoEpAnns
type instance Anno (FamilyDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (InjectivityAnn (GhcPass p)) = SrcAnn NoEpAnns
type instance Anno CType = SrcSpanAnnP
type instance Anno (HsDerivingClause (GhcPass p)) = SrcAnn NoEpAnns
type instance Anno (DerivClauseTys (GhcPass _)) = SrcSpanAnnC
type instance Anno (StandaloneKindSig (GhcPass p)) = SrcSpanAnnA
type instance Anno (ConDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno Bool = SrcAnn NoEpAnns
type instance Anno [LocatedA (ConDeclField (GhcPass _))] = SrcSpanAnnL
type instance Anno (FamEqn p (LocatedA (HsType p))) = SrcSpanAnnA
type instance Anno (TyFamInstDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (DataFamInstDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (FamEqn (GhcPass p) _) = SrcSpanAnnA
type instance Anno (ClsInstDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (InstDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (DocDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (DerivDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno OverlapMode = SrcSpanAnnP
type instance Anno (DerivStrategy (GhcPass p)) = SrcAnn NoEpAnns
type instance Anno (DefaultDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (ForeignDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (RuleDecls (GhcPass p)) = SrcSpanAnnA
type instance Anno (RuleDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (SourceText, RuleName) = SrcAnn NoEpAnns
type instance Anno (RuleBndr (GhcPass p)) = SrcAnn NoEpAnns
type instance Anno (WarnDecls (GhcPass p)) = SrcSpanAnnA
type instance Anno (WarnDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (AnnDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (RoleAnnotDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (Maybe Role) = SrcAnn NoEpAnns
type instance Anno CCallConv = SrcSpan
type instance Anno Safety = SrcSpan
type instance Anno CExportSpec = SrcSpan