{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE UndecidableInstances #-} -- Wrinkle in Note [Trees That Grow]
                                      -- in module Language.Haskell.Syntax.Extension

{-# OPTIONS_GHC -Wno-orphans #-} -- Outputable
{-# LANGUAGE InstanceSigs #-}

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

-- | Abstract syntax of global declarations.
--
-- Definitions for: @SynDecl@ and @ConDecl@, @ClassDecl@,
-- @InstDecl@, @DefaultDecl@ and @ForeignDecl@.
module GHC.Hs.Decls (
  -- * Toplevel declarations
  HsDecl(..), LHsDecl, HsDataDefn(..), HsDeriving, LHsFunDep,
  HsDerivingClause(..), LHsDerivingClause, DerivClauseTys(..), LDerivClauseTys,
  NewOrData, newOrDataToFlavour, anyLConIsGadt,
  StandaloneKindSig(..), LStandaloneKindSig, standaloneKindSigName,

  -- ** Class or type declarations
  TyClDecl(..), LTyClDecl, DataDeclRn(..),
  AnnDataDefn(..),
  AnnClassDecl(..),
  AnnSynDecl(..),
  AnnFamilyDecl(..),
  AnnClsInstDecl(..),
  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,

  -- ** Instance declarations
  InstDecl(..), LInstDecl, FamilyInfo(..),
  TyFamInstDecl(..), LTyFamInstDecl, instDeclDataFamInsts,
  TyFamDefltDecl, LTyFamDefltDecl,
  DataFamInstDecl(..), LDataFamInstDecl,
  pprDataFamInstFlavour, pprTyFamInstDecl, pprHsFamInstLHS,
  FamEqn(..), TyFamInstEqn, LTyFamInstEqn, HsFamEqnPats,
  LClsInstDecl, ClsInstDecl(..),

  -- ** Standalone deriving declarations
  DerivDecl(..), LDerivDecl, AnnDerivDecl,
  -- ** Deriving strategies
  DerivStrategy(..), LDerivStrategy,
  derivStrategyName, foldDerivStrategy, mapDerivStrategy,
  XViaStrategyPs(..),
  -- ** @RULE@ declarations
  LRuleDecls,RuleDecls(..),RuleDecl(..),LRuleDecl,HsRuleRn(..),
  HsRuleAnn(..), ActivationAnn(..),
  RuleBndr(..),LRuleBndr,
  collectRuleBndrSigTys,
  flattenRuleDecls, pprFullRuleName,
  -- ** @default@ declarations
  DefaultDecl(..), LDefaultDecl,
  -- ** Template haskell declaration splice
  SpliceDecoration(..),
  SpliceDecl(..), LSpliceDecl,
  -- ** Foreign function interface declarations
  ForeignDecl(..), LForeignDecl, ForeignImport(..), ForeignExport(..),
  CImportSpec(..),
  -- ** Data-constructor declarations
  ConDecl(..), LConDecl,
  HsConDeclH98Details, HsConDeclGADTDetails(..),
  AnnConDeclH98(..), AnnConDeclGADT(..),
  hsConDeclTheta,
  getConNames, getRecConArgs_maybe,
  -- ** Document comments
  DocDecl(..), LDocDecl, docDeclDoc,
  -- ** Deprecations
  WarnDecl(..), LWarnDecl,
  WarnDecls(..), LWarnDecls,
  -- ** Annotations
  AnnDecl(..), LAnnDecl,
  AnnProvenance(..), annProvenanceName_maybe,
  -- ** Role annotations
  RoleAnnotDecl(..), LRoleAnnotDecl, roleAnnotDeclName,
  -- ** Injective type families
  FamilyResultSig(..), LFamilyResultSig, InjectivityAnn(..), LInjectivityAnn,
  resultVariableName, familyDeclLName, familyDeclName,

  -- * Grouping
  HsGroup(..),  emptyRdrGroup, emptyRnGroup, appendGroups, hsGroupInstDecls,
  hsGroupTopLevelFixitySigs,

  partitionBindsAndSigs,
    ) where

-- friends:
import GHC.Prelude

import Language.Haskell.Syntax.Decls

import {-# SOURCE #-} GHC.Hs.Expr ( pprExpr, pprUntypedSplice )
        -- Because Expr imports Decls via HsBracket

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

-- others:
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.Types.ForeignCall
import GHC.Unit.Module.Warnings

import GHC.Data.Maybe
import Data.Data (Data)
import Data.List (concatMap)
import Data.Foldable (toList)

{-
************************************************************************
*                                                                      *
\subsection[HsDecl]{Declarations}
*                                                                      *
************************************************************************
-}

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

-- | Partition a list of HsDecls into function/pattern bindings, signatures,
-- type family declarations, type family instances, and documentation comments.
--
-- Panics when given a declaration that cannot be put into any of the output
-- groups.
--
-- The primary use of this function is to implement
-- 'GHC.Parser.PostProcess.cvBindsAndSigs'.
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 = [LHsDecl GhcPs]
-> (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs],
    [LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs])
[GenLocated SrcSpanAnnA (HsDecl GhcPs)]
-> ([GenLocated SrcSpanAnnA (HsBind GhcPs)],
    [GenLocated SrcSpanAnnA (Sig GhcPs)],
    [GenLocated SrcSpanAnnA (FamilyDecl GhcPs)],
    [GenLocated SrcSpanAnnA (TyFamInstDecl GhcPs)],
    [GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)],
    [GenLocated SrcSpanAnnA (DocDecl GhcPs)])
forall {p} {l}.
Outputable (HsDecl p) =>
[GenLocated l (HsDecl p)]
-> ([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)]
-> ([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 [] = ([], [], [], [], [], [])
    go ((L l
l HsDecl p
decl) : [GenLocated l (HsDecl p)]
ds) =
      let ([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)]
-> ([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
          -> (l -> HsBind p -> GenLocated l (HsBind p)
forall l e. l -> e -> GenLocated l e
L l
l HsBind p
b GenLocated l (HsBind p)
-> [GenLocated l (HsBind p)] -> [GenLocated l (HsBind p)]
forall a. a -> [a] -> [a]
: [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
          -> ([GenLocated l (HsBind p)]
bs, l -> Sig p -> GenLocated l (Sig p)
forall l e. l -> e -> GenLocated l e
L l
l Sig p
s GenLocated l (Sig p)
-> [GenLocated l (Sig p)] -> [GenLocated l (Sig p)]
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)
          -> ([GenLocated l (HsBind p)]
bs, [GenLocated l (Sig p)]
ss, l -> FamilyDecl p -> GenLocated l (FamilyDecl p)
forall l e. l -> e -> GenLocated l e
L l
l FamilyDecl p
t GenLocated l (FamilyDecl p)
-> [GenLocated l (FamilyDecl p)] -> [GenLocated l (FamilyDecl p)]
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 })
          -> ([GenLocated l (HsBind p)]
bs, [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, l -> TyFamInstDecl p -> GenLocated l (TyFamInstDecl p)
forall l e. l -> e -> GenLocated l e
L l
l TyFamInstDecl p
tfi GenLocated l (TyFamInstDecl p)
-> [GenLocated l (TyFamInstDecl p)]
-> [GenLocated l (TyFamInstDecl p)]
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 })
          -> ([GenLocated l (HsBind p)]
bs, [GenLocated l (Sig p)]
ss, [GenLocated l (FamilyDecl p)]
ts, [GenLocated l (TyFamInstDecl p)]
tfis, l -> DataFamInstDecl p -> GenLocated l (DataFamInstDecl p)
forall l e. l -> e -> GenLocated l e
L l
l DataFamInstDecl p
dfi GenLocated l (DataFamInstDecl p)
-> [GenLocated l (DataFamInstDecl p)]
-> [GenLocated l (DataFamInstDecl p)]
forall a. a -> [a] -> [a]
: [GenLocated l (DataFamInstDecl p)]
dfis, [GenLocated l (DocDecl p)]
docs)
        DocD XDocD p
_ DocDecl p
d
          -> ([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, l -> DocDecl p -> GenLocated l (DocDecl p)
forall l e. l -> e -> GenLocated l e
L l
l DocDecl p
d GenLocated l (DocDecl p)
-> [GenLocated l (DocDecl p)] -> [GenLocated l (DocDecl p)]
forall a. a -> [a] -> [a]
: [GenLocated l (DocDecl p)]
docs)
        HsDecl p
_ -> String
-> SDoc
-> ([GenLocated l (HsBind p)], [GenLocated l (Sig p)],
    [GenLocated l (FamilyDecl p)], [GenLocated l (TyFamInstDecl p)],
    [GenLocated l (DataFamInstDecl p)], [GenLocated l (DocDecl p)])
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"partitionBindsAndSigs" (HsDecl p -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsDecl p
decl)

-- Okay, I need to reconstruct the document comments, but for now:
instance Outputable (DocDecl name) where
  ppr :: DocDecl name -> SDoc
ppr DocDecl name
_ = String -> SDoc
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 = HsGroup (GhcPass p)
forall (p :: Pass). HsGroup (GhcPass p)
emptyGroup { hs_valds = emptyValBindsIn }
emptyRnGroup :: forall (p :: Pass). HsGroup (GhcPass p)
emptyRnGroup  = HsGroup (GhcPass p)
forall (p :: Pass). HsGroup (GhcPass p)
emptyGroup { hs_valds = emptyValBindsOut }

emptyGroup :: forall (p :: Pass). HsGroup (GhcPass p)
emptyGroup = HsGroup { hs_ext :: XCHsGroup (GhcPass p)
hs_ext = XCHsGroup (GhcPass p)
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 = String -> HsValBinds (GhcPass p)
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 = [] }

-- | The fixity signatures for each top-level declaration and class method
-- in an 'HsGroup'.
-- See Note [Top-level fixity signatures in an HsGroup]
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)]
[GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
fixds [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
-> [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
-> [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
cls_fixds
  where
    cls_fixds :: [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
cls_fixds = [ SrcSpanAnnA
-> FixitySig (GhcPass p)
-> GenLocated SrcSpanAnnA (FixitySig (GhcPass p))
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} <- [TyClGroup (GhcPass p)] -> [LTyClDecl (GhcPass p)]
forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LTyClDecl (GhcPass p)]
tyClGroupTyClDecls [TyClGroup (GhcPass p)]
tyclds
                , L SrcSpanAnnA
loc (FixSig XFixSig (GhcPass p)
_ FixitySig (GhcPass p)
sig) <- [LSig (GhcPass p)]
[GenLocated SrcSpanAnnA (Sig (GhcPass p))]
sigs
                ]

hsGroupInstDecls :: HsGroup (GhcPass p) -> [LInstDecl (GhcPass p)]
hsGroupInstDecls :: forall (p :: Pass). HsGroup (GhcPass p) -> [LInstDecl (GhcPass p)]
hsGroupInstDecls = (TyClGroup (GhcPass p)
 -> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))])
-> [TyClGroup (GhcPass p)]
-> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
(=<<) TyClGroup (GhcPass p) -> [XRec (GhcPass p) (InstDecl (GhcPass p))]
TyClGroup (GhcPass p)
-> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))]
forall pass. TyClGroup pass -> [LInstDecl pass]
group_instds ([TyClGroup (GhcPass p)]
 -> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))])
-> (HsGroup (GhcPass p) -> [TyClGroup (GhcPass p)])
-> HsGroup (GhcPass p)
-> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsGroup (GhcPass p) -> [TyClGroup (GhcPass p)]
forall p. HsGroup p -> [TyClGroup p]
hs_tyclds

tyClGroupTyClDecls :: [TyClGroup (GhcPass p)] -> [LTyClDecl (GhcPass p)]
tyClGroupTyClDecls :: forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LTyClDecl (GhcPass p)]
tyClGroupTyClDecls = (TyClGroup (GhcPass p)
 -> [GenLocated SrcSpanAnnA (TyClDecl (GhcPass p))])
-> [TyClGroup (GhcPass p)]
-> [GenLocated SrcSpanAnnA (TyClDecl (GhcPass p))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
Data.List.concatMap TyClGroup (GhcPass p) -> [XRec (GhcPass p) (TyClDecl (GhcPass p))]
TyClGroup (GhcPass p)
-> [GenLocated SrcSpanAnnA (TyClDecl (GhcPass p))]
forall pass. TyClGroup pass -> [LTyClDecl pass]
group_tyclds

tyClGroupInstDecls :: [TyClGroup (GhcPass p)] -> [LInstDecl (GhcPass p)]
tyClGroupInstDecls :: forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LInstDecl (GhcPass p)]
tyClGroupInstDecls = (TyClGroup (GhcPass p)
 -> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))])
-> [TyClGroup (GhcPass p)]
-> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
Data.List.concatMap TyClGroup (GhcPass p) -> [XRec (GhcPass p) (InstDecl (GhcPass p))]
TyClGroup (GhcPass p)
-> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))]
forall pass. TyClGroup pass -> [LInstDecl pass]
group_instds

tyClGroupRoleDecls :: [TyClGroup (GhcPass p)] -> [LRoleAnnotDecl (GhcPass p)]
tyClGroupRoleDecls :: forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LRoleAnnotDecl (GhcPass p)]
tyClGroupRoleDecls = (TyClGroup (GhcPass p)
 -> [GenLocated SrcSpanAnnA (RoleAnnotDecl (GhcPass p))])
-> [TyClGroup (GhcPass p)]
-> [GenLocated SrcSpanAnnA (RoleAnnotDecl (GhcPass p))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
Data.List.concatMap TyClGroup (GhcPass p)
-> [XRec (GhcPass p) (RoleAnnotDecl (GhcPass p))]
TyClGroup (GhcPass p)
-> [GenLocated SrcSpanAnnA (RoleAnnotDecl (GhcPass p))]
forall pass. TyClGroup pass -> [LRoleAnnotDecl pass]
group_roles

tyClGroupKindSigs :: [TyClGroup (GhcPass p)] -> [LStandaloneKindSig (GhcPass p)]
tyClGroupKindSigs :: forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LStandaloneKindSig (GhcPass p)]
tyClGroupKindSigs = (TyClGroup (GhcPass p)
 -> [GenLocated SrcSpanAnnA (StandaloneKindSig (GhcPass p))])
-> [TyClGroup (GhcPass p)]
-> [GenLocated SrcSpanAnnA (StandaloneKindSig (GhcPass p))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
Data.List.concatMap TyClGroup (GhcPass p)
-> [XRec (GhcPass p) (StandaloneKindSig (GhcPass p))]
TyClGroup (GhcPass p)
-> [GenLocated SrcSpanAnnA (StandaloneKindSig (GhcPass p))]
forall pass. TyClGroup pass -> [LStandaloneKindSig pass]
group_kisigs

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    = XCHsGroup (GhcPass p)
NoExtField
noExtField,
        hs_valds :: HsValBinds (GhcPass p)
hs_valds  = HsValBinds (GhcPass p)
val_groups1 HsValBinds (GhcPass p)
-> HsValBinds (GhcPass p) -> HsValBinds (GhcPass p)
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)]
[GenLocated SrcSpanAnnA (SpliceDecl (GhcPass p))]
spliceds1 [GenLocated SrcSpanAnnA (SpliceDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (SpliceDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (SpliceDecl (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LSpliceDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (SpliceDecl (GhcPass p))]
spliceds2,
        hs_tyclds :: [TyClGroup (GhcPass p)]
hs_tyclds = [TyClGroup (GhcPass p)]
tyclds1 [TyClGroup (GhcPass p)]
-> [TyClGroup (GhcPass p)] -> [TyClGroup (GhcPass p)]
forall a. [a] -> [a] -> [a]
++ [TyClGroup (GhcPass p)]
tyclds2,
        hs_derivds :: [LDerivDecl (GhcPass p)]
hs_derivds = [LDerivDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DerivDecl (GhcPass p))]
derivds1 [GenLocated SrcSpanAnnA (DerivDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (DerivDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (DerivDecl (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LDerivDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DerivDecl (GhcPass p))]
derivds2,
        hs_fixds :: [LFixitySig (GhcPass p)]
hs_fixds  = [LFixitySig (GhcPass p)]
[GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
fixds1 [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
-> [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
-> [GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LFixitySig (GhcPass p)]
[GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
fixds2,
        hs_annds :: [LAnnDecl (GhcPass p)]
hs_annds  = [LAnnDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (AnnDecl (GhcPass p))]
annds1 [GenLocated SrcSpanAnnA (AnnDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (AnnDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (AnnDecl (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LAnnDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (AnnDecl (GhcPass p))]
annds2,
        hs_defds :: [LDefaultDecl (GhcPass p)]
hs_defds  = [LDefaultDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DefaultDecl (GhcPass p))]
defds1 [GenLocated SrcSpanAnnA (DefaultDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (DefaultDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (DefaultDecl (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LDefaultDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DefaultDecl (GhcPass p))]
defds2,
        hs_fords :: [LForeignDecl (GhcPass p)]
hs_fords  = [LForeignDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (ForeignDecl (GhcPass p))]
fords1 [GenLocated SrcSpanAnnA (ForeignDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (ForeignDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (ForeignDecl (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LForeignDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (ForeignDecl (GhcPass p))]
fords2,
        hs_warnds :: [LWarnDecls (GhcPass p)]
hs_warnds = [LWarnDecls (GhcPass p)]
[GenLocated SrcSpanAnnA (WarnDecls (GhcPass p))]
warnds1 [GenLocated SrcSpanAnnA (WarnDecls (GhcPass p))]
-> [GenLocated SrcSpanAnnA (WarnDecls (GhcPass p))]
-> [GenLocated SrcSpanAnnA (WarnDecls (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LWarnDecls (GhcPass p)]
[GenLocated SrcSpanAnnA (WarnDecls (GhcPass p))]
warnds2,
        hs_ruleds :: [LRuleDecls (GhcPass p)]
hs_ruleds = [LRuleDecls (GhcPass p)]
[GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
rulds1 [GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
-> [GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
-> [GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LRuleDecls (GhcPass p)]
[GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
rulds2,
        hs_docs :: [LDocDecl (GhcPass p)]
hs_docs   = [LDocDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DocDecl (GhcPass p))]
docs1  [GenLocated SrcSpanAnnA (DocDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (DocDecl (GhcPass p))]
-> [GenLocated SrcSpanAnnA (DocDecl (GhcPass p))]
forall a. [a] -> [a] -> [a]
++ [LDocDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DocDecl (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)             = TyClDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyClDecl (GhcPass p)
dcl
    ppr (ValD XValD (GhcPass p)
_ HsBind (GhcPass p)
binds)            = HsBind (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsBind (GhcPass p)
binds
    ppr (DefD XDefD (GhcPass p)
_ DefaultDecl (GhcPass p)
def)              = DefaultDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr DefaultDecl (GhcPass p)
def
    ppr (InstD XInstD (GhcPass p)
_ InstDecl (GhcPass p)
inst)            = InstDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr InstDecl (GhcPass p)
inst
    ppr (DerivD XDerivD (GhcPass p)
_ DerivDecl (GhcPass p)
deriv)          = DerivDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr DerivDecl (GhcPass p)
deriv
    ppr (ForD XForD (GhcPass p)
_ ForeignDecl (GhcPass p)
fd)               = ForeignDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ForeignDecl (GhcPass p)
fd
    ppr (SigD XSigD (GhcPass p)
_ Sig (GhcPass p)
sd)               = Sig (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr Sig (GhcPass p)
sd
    ppr (KindSigD XKindSigD (GhcPass p)
_ StandaloneKindSig (GhcPass p)
ksd)          = StandaloneKindSig (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr StandaloneKindSig (GhcPass p)
ksd
    ppr (RuleD XRuleD (GhcPass p)
_ RuleDecls (GhcPass p)
rd)              = RuleDecls (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr RuleDecls (GhcPass p)
rd
    ppr (WarningD XWarningD (GhcPass p)
_ WarnDecls (GhcPass p)
wd)           = WarnDecls (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr WarnDecls (GhcPass p)
wd
    ppr (AnnD XAnnD (GhcPass p)
_ AnnDecl (GhcPass p)
ad)               = AnnDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr AnnDecl (GhcPass p)
ad
    ppr (SpliceD XSpliceD (GhcPass p)
_ SpliceDecl (GhcPass p)
dd)            = SpliceDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr SpliceDecl (GhcPass p)
dd
    ppr (DocD XDocD (GhcPass p)
_ DocDecl (GhcPass p)
doc)              = DocDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr DocDecl (GhcPass p)
doc
    ppr (RoleAnnotD XRoleAnnotD (GhcPass p)
_ RoleAnnotDecl (GhcPass p)
ra)         = RoleAnnotDecl (GhcPass p) -> SDoc
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 SDoc
forall doc. IsOutput doc => doc
empty
            [[GenLocated SrcSpanAnnA (FixitySig (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LFixitySig (GhcPass p)]
[GenLocated SrcSpanAnnA (FixitySig (GhcPass p))]
fix_decls, [GenLocated SrcSpanAnnA (DefaultDecl (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LDefaultDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DefaultDecl (GhcPass p))]
default_decls,
             [GenLocated SrcSpanAnnA (WarnDecls (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LWarnDecls (GhcPass p)]
[GenLocated SrcSpanAnnA (WarnDecls (GhcPass p))]
deprec_decls, [GenLocated SrcSpanAnnA (AnnDecl (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LAnnDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (AnnDecl (GhcPass p))]
ann_decls,
             [GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LRuleDecls (GhcPass p)]
[GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
rule_decls,
             if HsValBinds (GhcPass p) -> Bool
forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b) -> Bool
isEmptyValBinds HsValBinds (GhcPass p)
val_decls
                then Maybe SDoc
forall a. Maybe a
Nothing
                else SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (HsValBinds (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsValBinds (GhcPass p)
val_decls),
             [GenLocated SrcSpanAnnA (RoleAnnotDecl (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds ([TyClGroup (GhcPass p)] -> [LRoleAnnotDecl (GhcPass p)]
forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LRoleAnnotDecl (GhcPass p)]
tyClGroupRoleDecls [TyClGroup (GhcPass p)]
tycl_decls),
             [GenLocated SrcSpanAnnA (StandaloneKindSig (GhcPass p))]
-> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds ([TyClGroup (GhcPass p)] -> [LStandaloneKindSig (GhcPass p)]
forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LStandaloneKindSig (GhcPass p)]
tyClGroupKindSigs  [TyClGroup (GhcPass p)]
tycl_decls),
             [GenLocated SrcSpanAnnA (TyClDecl (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds ([TyClGroup (GhcPass p)] -> [LTyClDecl (GhcPass p)]
forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LTyClDecl (GhcPass p)]
tyClGroupTyClDecls [TyClGroup (GhcPass p)]
tycl_decls),
             [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds ([TyClGroup (GhcPass p)] -> [LInstDecl (GhcPass p)]
forall (p :: Pass).
[TyClGroup (GhcPass p)] -> [LInstDecl (GhcPass p)]
tyClGroupInstDecls [TyClGroup (GhcPass p)]
tycl_decls),
             [GenLocated SrcSpanAnnA (DerivDecl (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LDerivDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DerivDecl (GhcPass p))]
deriv_decls,
             [GenLocated SrcSpanAnnA (ForeignDecl (GhcPass p))] -> Maybe SDoc
forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [LForeignDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (ForeignDecl (GhcPass p))]
foreign_decls]
        where
          ppr_ds :: Outputable a => [a] -> Maybe SDoc
          ppr_ds :: forall a. Outputable a => [a] -> Maybe SDoc
ppr_ds [] = Maybe SDoc
forall a. Maybe a
Nothing
          ppr_ds [a]
ds = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((a -> SDoc) -> [a] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map a -> SDoc
forall a. Outputable a => a -> SDoc
ppr [a]
ds))

          vcat_mb :: SDoc -> [Maybe SDoc] -> SDoc
          -- Concatenate vertically with white-space between non-blanks
          vcat_mb :: SDoc -> [Maybe SDoc] -> SDoc
vcat_mb SDoc
_    []             = 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 SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ SDoc
d SDoc -> SDoc -> SDoc
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) = Bool
-> Maybe SplicePointName -> HsUntypedSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Bool
-> Maybe SplicePointName -> HsUntypedSplice (GhcPass p) -> SDoc
pprUntypedSplice Bool
True Maybe SplicePointName
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)   = Bool
-> Maybe SplicePointName -> HsUntypedSplice (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Bool
-> Maybe SplicePointName -> HsUntypedSplice (GhcPass p) -> SDoc
pprUntypedSplice Bool
False Maybe SplicePointName
forall a. Maybe a
Nothing HsUntypedSplice (GhcPass p)
e

instance Outputable SpliceDecoration where
  ppr :: SpliceDecoration -> SDoc
ppr SpliceDecoration
x = String -> SDoc
forall doc. IsLine doc => String -> doc
text (String -> SDoc) -> String -> SDoc
forall a b. (a -> b) -> a -> b
$ SpliceDecoration -> String
forall a. Show a => a -> String
show SpliceDecoration
x



{-
************************************************************************
*                                                                      *
            Type and class declarations
*                                                                      *
************************************************************************
-}

type instance XFamDecl      (GhcPass _) = NoExtField

type instance XSynDecl      GhcPs = AnnSynDecl
type instance XSynDecl      GhcRn = NameSet -- FVs
type instance XSynDecl      GhcTc = NameSet -- FVs

type instance XDataDecl     GhcPs = NoExtField
type instance XDataDecl     GhcRn = DataDeclRn
type instance XDataDecl     GhcTc = DataDeclRn

data DataDeclRn = DataDeclRn
             { DataDeclRn -> Bool
tcdDataCusk :: Bool    -- ^ does this have a CUSK?
                 -- See Note [CUSKs: complete user-supplied kind signatures]
             , DataDeclRn -> NameSet
tcdFVs      :: NameSet }
  deriving Typeable DataDeclRn
Typeable DataDeclRn =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DataDeclRn -> c DataDeclRn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataDeclRn)
-> (DataDeclRn -> Constr)
-> (DataDeclRn -> DataType)
-> (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))
-> ((forall b. Data b => b -> b) -> DataDeclRn -> DataDeclRn)
-> (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 u. (forall d. Data d => d -> u) -> DataDeclRn -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DataDeclRn -> u)
-> (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 (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn)
-> Data DataDeclRn
DataDeclRn -> Constr
DataDeclRn -> DataType
(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)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclRn -> c DataDeclRn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataDeclRn -> c DataDeclRn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclRn
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataDeclRn
$ctoConstr :: DataDeclRn -> Constr
toConstr :: DataDeclRn -> Constr
$cdataTypeOf :: DataDeclRn -> DataType
dataTypeOf :: DataDeclRn -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclRn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataDeclRn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDeclRn)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDeclRn)
$cgmapT :: (forall b. Data b => b -> b) -> DataDeclRn -> DataDeclRn
gmapT :: (forall b. Data b => b -> b) -> DataDeclRn -> DataDeclRn
$cgmapQl :: 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
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataDeclRn -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataDeclRn -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataDeclRn -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDeclRn -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataDeclRn -> u
$cgmapM :: forall (m :: * -> *).
Monad 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
$cgmapMp :: 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
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataDeclRn -> m DataDeclRn
Data

type instance XClassDecl    GhcPs =
  ( AnnClassDecl
  , EpLayout              -- See Note [Class EpLayout]
  , AnnSortKey DeclTag )  -- TODO:AZ:tidy up AnnSortKey

type instance XClassDecl    GhcRn = NameSet -- FVs
type instance XClassDecl    GhcTc = NameSet -- FVs

type instance XXTyClDecl    (GhcPass _) = DataConCantHappen

type instance XCTyFamInstDecl (GhcPass _) = (EpToken "type", EpToken "instance")
type instance XXTyFamInstDecl (GhcPass _) = DataConCantHappen

data AnnDataDefn
  = AnnDataDefn {
      AnnDataDefn -> [EpToken "("]
andd_openp    :: [EpToken "("],
      AnnDataDefn -> [EpToken ")"]
andd_closep   :: [EpToken ")"],
      AnnDataDefn -> EpToken "type"
andd_type     :: EpToken "type",
      AnnDataDefn -> EpToken "newtype"
andd_newtype  :: EpToken "newtype",
      AnnDataDefn -> EpToken "data"
andd_data     :: EpToken "data",
      AnnDataDefn -> EpToken "instance"
andd_instance :: EpToken "instance",
      AnnDataDefn -> TokDcolon
andd_dcolon   :: TokDcolon,
      AnnDataDefn -> EpToken "where"
andd_where    :: EpToken "where",
      AnnDataDefn -> EpToken "{"
andd_openc    :: EpToken "{",
      AnnDataDefn -> EpToken "}"
andd_closec   :: EpToken "}",
      AnnDataDefn -> EpToken "="
andd_equal    :: EpToken "="
  } deriving Typeable AnnDataDefn
Typeable AnnDataDefn =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnDataDefn -> c AnnDataDefn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnDataDefn)
-> (AnnDataDefn -> Constr)
-> (AnnDataDefn -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnDataDefn))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnDataDefn))
-> ((forall b. Data b => b -> b) -> AnnDataDefn -> AnnDataDefn)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnDataDefn -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnDataDefn -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn)
-> Data AnnDataDefn
AnnDataDefn -> Constr
AnnDataDefn -> DataType
(forall b. Data b => b -> b) -> AnnDataDefn -> AnnDataDefn
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) -> AnnDataDefn -> u
forall u. (forall d. Data d => d -> u) -> AnnDataDefn -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnDataDefn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnDataDefn -> c AnnDataDefn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnDataDefn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnDataDefn)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnDataDefn -> c AnnDataDefn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnDataDefn -> c AnnDataDefn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnDataDefn
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnDataDefn
$ctoConstr :: AnnDataDefn -> Constr
toConstr :: AnnDataDefn -> Constr
$cdataTypeOf :: AnnDataDefn -> DataType
dataTypeOf :: AnnDataDefn -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnDataDefn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnDataDefn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnDataDefn)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnDataDefn)
$cgmapT :: (forall b. Data b => b -> b) -> AnnDataDefn -> AnnDataDefn
gmapT :: (forall b. Data b => b -> b) -> AnnDataDefn -> AnnDataDefn
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnDataDefn -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnDataDefn -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnDataDefn -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnDataDefn -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnDataDefn -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnDataDefn -> m AnnDataDefn
Data

instance NoAnn AnnDataDefn where
  noAnn :: AnnDataDefn
noAnn = [EpToken "("]
-> [EpToken ")"]
-> EpToken "type"
-> EpToken "newtype"
-> EpToken "data"
-> EpToken "instance"
-> TokDcolon
-> EpToken "where"
-> EpToken "{"
-> EpToken "}"
-> EpToken "="
-> AnnDataDefn
AnnDataDefn [EpToken "("]
forall a. NoAnn a => a
noAnn [EpToken ")"]
forall a. NoAnn a => a
noAnn EpToken "type"
forall a. NoAnn a => a
noAnn EpToken "newtype"
forall a. NoAnn a => a
noAnn EpToken "data"
forall a. NoAnn a => a
noAnn EpToken "instance"
forall a. NoAnn a => a
noAnn TokDcolon
forall a. NoAnn a => a
noAnn EpToken "where"
forall a. NoAnn a => a
noAnn EpToken "{"
forall a. NoAnn a => a
noAnn EpToken "}"
forall a. NoAnn a => a
noAnn EpToken "="
forall a. NoAnn a => a
noAnn

data AnnClassDecl
  = AnnClassDecl {
      AnnClassDecl -> EpToken "class"
acd_class  :: EpToken "class",
      AnnClassDecl -> [EpToken "("]
acd_openp  :: [EpToken "("],
      AnnClassDecl -> [EpToken ")"]
acd_closep :: [EpToken ")"],
      AnnClassDecl -> EpToken "|"
acd_vbar   :: EpToken "|",
      AnnClassDecl -> EpToken "where"
acd_where  :: EpToken "where",
      AnnClassDecl -> EpToken "{"
acd_openc  :: EpToken "{",
      AnnClassDecl -> EpToken "}"
acd_closec :: EpToken "}",
      AnnClassDecl -> [EpToken ";"]
acd_semis  :: [EpToken ";"]
  } deriving Typeable AnnClassDecl
Typeable AnnClassDecl =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnClassDecl -> c AnnClassDecl)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnClassDecl)
-> (AnnClassDecl -> Constr)
-> (AnnClassDecl -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnClassDecl))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnClassDecl))
-> ((forall b. Data b => b -> b) -> AnnClassDecl -> AnnClassDecl)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnClassDecl -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnClassDecl -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl)
-> Data AnnClassDecl
AnnClassDecl -> Constr
AnnClassDecl -> DataType
(forall b. Data b => b -> b) -> AnnClassDecl -> AnnClassDecl
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) -> AnnClassDecl -> u
forall u. (forall d. Data d => d -> u) -> AnnClassDecl -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnClassDecl
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnClassDecl -> c AnnClassDecl
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnClassDecl)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnClassDecl)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnClassDecl -> c AnnClassDecl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnClassDecl -> c AnnClassDecl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnClassDecl
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnClassDecl
$ctoConstr :: AnnClassDecl -> Constr
toConstr :: AnnClassDecl -> Constr
$cdataTypeOf :: AnnClassDecl -> DataType
dataTypeOf :: AnnClassDecl -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnClassDecl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnClassDecl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnClassDecl)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnClassDecl)
$cgmapT :: (forall b. Data b => b -> b) -> AnnClassDecl -> AnnClassDecl
gmapT :: (forall b. Data b => b -> b) -> AnnClassDecl -> AnnClassDecl
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClassDecl -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnClassDecl -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnClassDecl -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnClassDecl -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnClassDecl -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnClassDecl -> m AnnClassDecl
Data

instance NoAnn AnnClassDecl where
  noAnn :: AnnClassDecl
noAnn = EpToken "class"
-> [EpToken "("]
-> [EpToken ")"]
-> EpToken "|"
-> EpToken "where"
-> EpToken "{"
-> EpToken "}"
-> [EpToken ";"]
-> AnnClassDecl
AnnClassDecl EpToken "class"
forall a. NoAnn a => a
noAnn [EpToken "("]
forall a. NoAnn a => a
noAnn [EpToken ")"]
forall a. NoAnn a => a
noAnn EpToken "|"
forall a. NoAnn a => a
noAnn EpToken "where"
forall a. NoAnn a => a
noAnn EpToken "{"
forall a. NoAnn a => a
noAnn EpToken "}"
forall a. NoAnn a => a
noAnn [EpToken ";"]
forall a. NoAnn a => a
noAnn

data AnnSynDecl
  = AnnSynDecl {
    AnnSynDecl -> [EpToken "("]
asd_opens  :: [EpToken "("],
    AnnSynDecl -> [EpToken ")"]
asd_closes :: [EpToken ")"],
    AnnSynDecl -> EpToken "type"
asd_type   :: EpToken "type",
    AnnSynDecl -> EpToken "="
asd_equal  :: EpToken "="
  } deriving Typeable AnnSynDecl
Typeable AnnSynDecl =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnSynDecl -> c AnnSynDecl)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnSynDecl)
-> (AnnSynDecl -> Constr)
-> (AnnSynDecl -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnSynDecl))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnSynDecl))
-> ((forall b. Data b => b -> b) -> AnnSynDecl -> AnnSynDecl)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnSynDecl -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnSynDecl -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl)
-> Data AnnSynDecl
AnnSynDecl -> Constr
AnnSynDecl -> DataType
(forall b. Data b => b -> b) -> AnnSynDecl -> AnnSynDecl
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) -> AnnSynDecl -> u
forall u. (forall d. Data d => d -> u) -> AnnSynDecl -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSynDecl
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSynDecl -> c AnnSynDecl
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSynDecl)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSynDecl)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSynDecl -> c AnnSynDecl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnSynDecl -> c AnnSynDecl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSynDecl
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnSynDecl
$ctoConstr :: AnnSynDecl -> Constr
toConstr :: AnnSynDecl -> Constr
$cdataTypeOf :: AnnSynDecl -> DataType
dataTypeOf :: AnnSynDecl -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSynDecl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnSynDecl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSynDecl)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnnSynDecl)
$cgmapT :: (forall b. Data b => b -> b) -> AnnSynDecl -> AnnSynDecl
gmapT :: (forall b. Data b => b -> b) -> AnnSynDecl -> AnnSynDecl
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnSynDecl -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnSynDecl -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnSynDecl -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnSynDecl -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnSynDecl -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnSynDecl -> m AnnSynDecl
Data

instance NoAnn AnnSynDecl where
  noAnn :: AnnSynDecl
noAnn = [EpToken "("]
-> [EpToken ")"] -> EpToken "type" -> EpToken "=" -> AnnSynDecl
AnnSynDecl [EpToken "("]
forall a. NoAnn a => a
noAnn [EpToken ")"]
forall a. NoAnn a => a
noAnn EpToken "type"
forall a. NoAnn a => a
noAnn EpToken "="
forall a. NoAnn a => a
noAnn

------------- Pretty printing FamilyDecls -----------

pprFlavour :: FamilyInfo pass -> SDoc
pprFlavour :: forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo pass
DataFamily            = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"data"
pprFlavour FamilyInfo pass
OpenTypeFamily        = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type"
pprFlavour (ClosedTypeFamily {}) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type"

instance Outputable (FamilyInfo pass) where
  ppr :: FamilyInfo pass -> SDoc
ppr FamilyInfo pass
info = FamilyInfo pass -> SDoc
forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo pass
info SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"family"


-- Dealing with names

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 = GenLocated SrcSpanAnnN (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc (GenLocated SrcSpanAnnN (IdGhcP p) -> IdGhcP p)
-> (TyFamInstDecl (GhcPass p) -> GenLocated SrcSpanAnnN (IdGhcP p))
-> TyFamInstDecl (GhcPass p)
-> IdGhcP p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TyFamInstDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
TyFamInstDecl (GhcPass p) -> GenLocated SrcSpanAnnN (IdGhcP p)
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)
GenLocated SrcSpanAnnN (IdP (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 })     = FamilyDecl (GhcPass p) -> XRecGhc (IdGhcP p)
forall (p :: Pass). FamilyDecl (GhcPass p) -> XRecGhc (IdGhcP p)
familyDeclLName FamilyDecl (GhcPass p)
fd
tyClDeclLName (SynDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ln })   = LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdP (GhcPass p))
ln
tyClDeclLName (DataDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ln })  = LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdP (GhcPass p))
ln
tyClDeclLName (ClassDecl { tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP (GhcPass p)
ln }) = LIdP (GhcPass p)
GenLocated SrcSpanAnnN (IdP (GhcPass p))
ln

tyClDeclTyVars :: TyClDecl (GhcPass p) -> LHsQTyVars (GhcPass p)
tyClDeclTyVars :: forall (p :: Pass). TyClDecl (GhcPass p) -> LHsQTyVars (GhcPass p)
tyClDeclTyVars (FamDecl { tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam = FamilyDecl { fdTyVars :: forall pass. FamilyDecl pass -> LHsQTyVars pass
fdTyVars = LHsQTyVars (GhcPass p)
tvs } }) = LHsQTyVars (GhcPass p)
tvs
tyClDeclTyVars TyClDecl (GhcPass p)
d = TyClDecl (GhcPass p) -> LHsQTyVars (GhcPass p)
forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars TyClDecl (GhcPass p)
d

countTyClDecls :: [TyClDecl pass] -> (Int, Int, Int, Int, Int)
        -- class, synonym decls, data, newtype, family decls
countTyClDecls :: forall pass. [TyClDecl pass] -> (Int, Int, Int, Int, Int)
countTyClDecls [TyClDecl pass]
decls
 = ((TyClDecl pass -> Bool) -> [TyClDecl pass] -> Int
forall a. (a -> Bool) -> [a] -> Int
count TyClDecl pass -> Bool
forall pass. TyClDecl pass -> Bool
isClassDecl    [TyClDecl pass]
decls,
    (TyClDecl pass -> Bool) -> [TyClDecl pass] -> Int
forall a. (a -> Bool) -> [a] -> Int
count TyClDecl pass -> Bool
forall pass. TyClDecl pass -> Bool
isSynDecl      [TyClDecl pass]
decls,  -- excluding...
    (TyClDecl pass -> Bool) -> [TyClDecl pass] -> Int
forall a. (a -> Bool) -> [a] -> Int
count TyClDecl pass -> Bool
forall pass. TyClDecl pass -> Bool
isDataTy       [TyClDecl pass]
decls,  -- ...family...
    (TyClDecl pass -> Bool) -> [TyClDecl pass] -> Int
forall a. (a -> Bool) -> [a] -> Int
count TyClDecl pass -> Bool
forall pass. TyClDecl pass -> Bool
isNewTy        [TyClDecl pass]
decls,  -- ...instances
    (TyClDecl pass -> Bool) -> [TyClDecl pass] -> Int
forall a. (a -> Bool) -> [a] -> Int
count TyClDecl pass -> Bool
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

-- FIXME: tcdName is commonly used by both GHC and third-party tools, so it
-- needs to be polymorphic in the pass
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 = GenLocated SrcSpanAnnN (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc (GenLocated SrcSpanAnnN (IdGhcP p) -> IdGhcP p)
-> (TyClDecl (GhcPass p) -> GenLocated SrcSpanAnnN (IdGhcP p))
-> TyClDecl (GhcPass p)
-> IdGhcP p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TyClDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
TyClDecl (GhcPass p) -> GenLocated SrcSpanAnnN (IdGhcP p)
forall (p :: Pass).
(Anno (IdGhcP p) ~ SrcSpanAnnN) =>
TyClDecl (GhcPass p) -> LocatedN (IdP (GhcPass p))
tyClDeclLName

-- | Does this declaration have a complete, user-supplied kind signature?
-- See Note [CUSKs: complete user-supplied kind signatures]
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 EpAnnCO
_ FamilyResultSig GhcRn
resultSig } }) =
    case FamilyInfo GhcRn
fam_info of
      ClosedTypeFamily {} -> LHsQTyVars GhcRn -> Bool
forall (p :: Pass). LHsQTyVars (GhcPass p) -> Bool
hsTvbAllKinded LHsQTyVars GhcRn
tyvars
                          Bool -> Bool -> Bool
&& Maybe (GenLocated SrcSpanAnnA (HsType GhcRn)) -> Bool
forall a. Maybe a -> Bool
isJust (FamilyResultSig GhcRn -> Maybe (LHsKind GhcRn)
forall (p :: Pass).
FamilyResultSig (GhcPass p) -> Maybe (LHsKind (GhcPass p))
famResultKindSignature FamilyResultSig GhcRn
resultSig)
      FamilyInfo GhcRn
_ -> Bool
True -- Un-associated open type/data families have CUSKs
hsDeclHasCusk (SynDecl { tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
tyvars, tcdRhs :: forall pass. TyClDecl pass -> LHsType pass
tcdRhs = LHsKind GhcRn
rhs })
  = LHsQTyVars GhcRn -> Bool
forall (p :: Pass). LHsQTyVars (GhcPass p) -> Bool
hsTvbAllKinded LHsQTyVars GhcRn
tyvars Bool -> Bool -> Bool
&& Maybe (GenLocated SrcSpanAnnA (HsType GhcRn)) -> Bool
forall a. Maybe a -> Bool
isJust (LHsKind GhcRn -> Maybe (LHsKind GhcRn)
forall (p :: Pass).
LHsType (GhcPass p) -> Maybe (LHsType (GhcPass p))
hsTyKindSig LHsKind 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 }) = LHsQTyVars GhcRn -> Bool
forall (p :: Pass). LHsQTyVars (GhcPass p) -> Bool
hsTvbAllKinded LHsQTyVars GhcRn
tyvars

-- Pretty-printing TyClDecl
-- ~~~~~~~~~~~~~~~~~~~~~~~~

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 }) = FamilyDecl (GhcPass p) -> SDoc
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 (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
              XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
XRecGhc (IdGhcP p)
ltycon LHsQTyVars (GhcPass p)
tyvars LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
Maybe
  (GenLocated
     SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
forall a. Maybe a
Nothing SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
forall doc. IsLine doc => doc
equals)
          Int
4 (GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
GenLocated SrcSpanAnnA (HsType (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 })
      = (Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
pp_data_defn (XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
XRecGhc (IdGhcP 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})
      | [GenLocated SrcSpanAnnA (Sig (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LSig (GhcPass p)]
[GenLocated SrcSpanAnnA (Sig (GhcPass p))]
sigs Bool -> Bool -> Bool
&& [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null LHsBinds (GhcPass p)
[GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
methods Bool -> Bool -> Bool
&& [GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LFamilyDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p))]
ats Bool -> Bool -> Bool
&& [GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LTyFamDefltDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))]
at_defs -- No "where" part
      = SDoc
top_matter

      | Bool
otherwise       -- Laid out
      = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
top_matter SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where"
             , Int -> SDoc -> SDoc
nest Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
pprDeclList ((GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (FamilyDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (FamilyDecl (GhcPass p) -> SDoc)
-> (GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p))
    -> FamilyDecl (GhcPass p))
-> GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p))
-> FamilyDecl (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [LFamilyDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (FamilyDecl (GhcPass p))]
ats [SDoc] -> [SDoc] -> [SDoc]
forall a. [a] -> [a] -> [a]
++
                                     (GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (TyFamInstDecl (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
TyFamDefltDecl (GhcPass p) -> SDoc
pprTyFamDefltDecl (TyFamInstDecl (GhcPass p) -> SDoc)
-> (GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))
    -> TyFamInstDecl (GhcPass p))
-> GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))
-> TyFamInstDecl (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [LTyFamDefltDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))]
at_defs [SDoc] -> [SDoc] -> [SDoc]
forall a. [a] -> [a] -> [a]
++
                                     LHsBinds (GhcPass p) -> [LSig (GhcPass p)] -> [SDoc]
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 = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"class"
                    SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
XRecGhc (IdGhcP p)
lclas LHsQTyVars (GhcPass p)
tyvars LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
context
                    SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [FunDep (GhcPass p)] -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
[FunDep (GhcPass p)] -> SDoc
pprFundeps ((GenLocated SrcSpanAnnA (FunDep (GhcPass p)) -> FunDep (GhcPass p))
-> [GenLocated SrcSpanAnnA (FunDep (GhcPass p))]
-> [FunDep (GhcPass p)]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (FunDep (GhcPass p)) -> FunDep (GhcPass p)
forall l e. GenLocated l e -> e
unLoc [LHsFunDep (GhcPass p)]
[GenLocated SrcSpanAnnA (FunDep (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 (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"TyClGroup") Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
      [GenLocated SrcSpanAnnA (StandaloneKindSig (GhcPass p))] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LStandaloneKindSig (GhcPass p)]
[GenLocated SrcSpanAnnA (StandaloneKindSig (GhcPass p))]
kisigs SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$
      [GenLocated SrcSpanAnnA (TyClDecl (GhcPass p))] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LTyClDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (TyClDecl (GhcPass p))]
tyclds SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$
      [GenLocated SrcSpanAnnA (RoleAnnotDecl (GhcPass p))] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LRoleAnnotDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (RoleAnnotDecl (GhcPass p))]
roles SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$
      [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LInstDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (InstDecl (GhcPass p))]
instds

pp_vanilla_decl_head :: (OutputableBndrId p)
   => XRecGhc (IdGhcP p)
   -> LHsQTyVars (GhcPass p)
   -> LexicalFixity
   -> Maybe (LHsContext (GhcPass p))
   -> SDoc
pp_vanilla_decl_head :: forall (p :: Pass).
OutputableBndrId p =>
XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head XRecGhc (IdGhcP p)
thing (HsQTvs { hsq_explicit :: forall pass.
LHsQTyVars pass -> [LHsTyVarBndr (HsBndrVis pass) pass]
hsq_explicit = [LHsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)]
tyvars }) LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
context
 = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [Maybe (LHsContext (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe (LHsContext (GhcPass p)) -> SDoc
pprLHsContext Maybe (LHsContext (GhcPass p))
context, [GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
-> SDoc
pp_tyvars [LHsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)]
[GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
tyvars]
  where
    pp_tyvars :: [GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
-> SDoc
pp_tyvars (GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
varl:[GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
varsr)
      | LexicalFixity
fixity LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix, GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
varr:varsr' :: [GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
varsr'@(GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
_:[GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
_) <- [GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
varsr
         -- If varsr has at least 2 elements, parenthesize.
         = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'(',HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)
forall l e. GenLocated l e -> e
unLoc GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
varl), IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc (XRecGhc (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc XRecGhc (IdGhcP p)
thing)
                , (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr(HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc)
-> (GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
    -> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> GenLocated
     SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
varr, Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
')'
                , [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep ((GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr(HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc)
-> (GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
    -> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> GenLocated
     SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
varsr')]
      | LexicalFixity
fixity LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix
         = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)
forall l e. GenLocated l e -> e
unLoc GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
varl), IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc (XRecGhc (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc XRecGhc (IdGhcP p)
thing)
         , [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep ((GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr(HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc)
-> (GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
    -> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> GenLocated
     SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
varsr)]
      | Bool
otherwise = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (XRecGhc (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc XRecGhc (IdGhcP p)
thing)
                  , [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep ((GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr(HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p) -> SDoc)
-> (GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
    -> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> GenLocated
     SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) (GenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
varlGenLocated
  SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))
-> [GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
-> [GenLocated
      SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
forall a. a -> [a] -> [a]
:[GenLocated
   SrcSpanAnnA (HsTyVarBndr (HsBndrVis (GhcPass p)) (GhcPass p))]
varsr))]
    pp_tyvars [] = IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (XRecGhc (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc XRecGhc (IdGhcP p)
thing)

pprTyClDeclFlavour :: TyClDecl (GhcPass p) -> SDoc
pprTyClDeclFlavour :: forall (p :: Pass). TyClDecl (GhcPass p) -> SDoc
pprTyClDeclFlavour (ClassDecl {})   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"class"
pprTyClDeclFlavour (SynDecl {})     = String -> SDoc
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 }})
  = FamilyInfo (GhcPass p) -> SDoc
forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo (GhcPass p)
info SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
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 } })
  = NewOrData -> SDoc
forall a. Outputable a => a -> SDoc
ppr (DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
-> NewOrData
forall a. DataDefnCons a -> NewOrData
dataDefnConsNewOrData DataDefnCons (LConDecl (GhcPass p))
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
nd)

instance OutputableBndrId p => Outputable (FunDep (GhcPass p)) where
  ppr :: FunDep (GhcPass p) -> SDoc
ppr = FunDep (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
FunDep (GhcPass p) -> SDoc
pprFunDep

type instance XCFunDep    (GhcPass _) = TokRarrow
type instance XXFunDep    (GhcPass _) = DataConCantHappen

pprFundeps :: OutputableBndrId p => [FunDep (GhcPass p)] -> SDoc
pprFundeps :: forall (p :: Pass).
OutputableBndrId p =>
[FunDep (GhcPass p)] -> SDoc
pprFundeps []  = SDoc
forall doc. IsOutput doc => doc
empty
pprFundeps [FunDep (GhcPass p)]
fds = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep (SDoc
forall doc. IsLine doc => doc
vbar SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
comma ((FunDep (GhcPass p) -> SDoc) -> [FunDep (GhcPass p)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map FunDep (GhcPass p) -> SDoc
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) = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [[GenLocated (Anno (IdGhcP p)) (IdGhcP p)] -> SDoc
forall a. Outputable a => [a] -> SDoc
interppSP [LIdP (GhcPass p)]
[GenLocated (Anno (IdGhcP p)) (IdGhcP p)]
us, SDoc
arrow, [GenLocated (Anno (IdGhcP p)) (IdGhcP p)] -> SDoc
forall a. Outputable a => [a] -> SDoc
interppSP [LIdP (GhcPass p)]
[GenLocated (Anno (IdGhcP p)) (IdGhcP p)]
vs]

{- *********************************************************************
*                                                                      *
                         TyClGroup
        Strongly connected components of
      type, class, instance, and role declarations
*                                                                      *
********************************************************************* -}

type instance XCTyClGroup (GhcPass _) = NoExtField
type instance XXTyClGroup (GhcPass _) = DataConCantHappen


{- *********************************************************************
*                                                                      *
               Data and type family declarations
*                                                                      *
********************************************************************* -}

type instance XNoSig            (GhcPass _) = NoExtField
type instance XCKindSig         (GhcPass _) = NoExtField

type instance XTyVarSig         (GhcPass _) = NoExtField
type instance XXFamilyResultSig (GhcPass _) = DataConCantHappen

type instance XCFamilyDecl    (GhcPass _) = AnnFamilyDecl
type instance XXFamilyDecl    (GhcPass _) = DataConCantHappen

data AnnFamilyDecl
  = AnnFamilyDecl {
      AnnFamilyDecl -> [EpToken "("]
afd_openp  :: [EpToken "("],
      AnnFamilyDecl -> [EpToken ")"]
afd_closep :: [EpToken ")"],
      AnnFamilyDecl -> EpToken "type"
afd_type   :: EpToken "type",
      AnnFamilyDecl -> EpToken "data"
afd_data   :: EpToken "data",
      AnnFamilyDecl -> EpToken "family"
afd_family :: EpToken "family",
      AnnFamilyDecl -> TokDcolon
afd_dcolon :: TokDcolon,
      AnnFamilyDecl -> EpToken "="
afd_equal  :: EpToken "=",
      AnnFamilyDecl -> EpToken "|"
afd_vbar   :: EpToken "|",
      AnnFamilyDecl -> EpToken "where"
afd_where  :: EpToken "where",
      AnnFamilyDecl -> EpToken "{"
afd_openc  :: EpToken "{",
      AnnFamilyDecl -> EpToken ".."
afd_dotdot :: EpToken "..",
      AnnFamilyDecl -> EpToken "}"
afd_closec :: EpToken "}"
  } deriving Typeable AnnFamilyDecl
Typeable AnnFamilyDecl =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnFamilyDecl -> c AnnFamilyDecl)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnFamilyDecl)
-> (AnnFamilyDecl -> Constr)
-> (AnnFamilyDecl -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnFamilyDecl))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnFamilyDecl))
-> ((forall b. Data b => b -> b) -> AnnFamilyDecl -> AnnFamilyDecl)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnFamilyDecl -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnFamilyDecl -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl)
-> Data AnnFamilyDecl
AnnFamilyDecl -> Constr
AnnFamilyDecl -> DataType
(forall b. Data b => b -> b) -> AnnFamilyDecl -> AnnFamilyDecl
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) -> AnnFamilyDecl -> u
forall u. (forall d. Data d => d -> u) -> AnnFamilyDecl -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnFamilyDecl
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnFamilyDecl -> c AnnFamilyDecl
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnFamilyDecl)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnFamilyDecl)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnFamilyDecl -> c AnnFamilyDecl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnFamilyDecl -> c AnnFamilyDecl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnFamilyDecl
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnFamilyDecl
$ctoConstr :: AnnFamilyDecl -> Constr
toConstr :: AnnFamilyDecl -> Constr
$cdataTypeOf :: AnnFamilyDecl -> DataType
dataTypeOf :: AnnFamilyDecl -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnFamilyDecl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnFamilyDecl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnFamilyDecl)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnFamilyDecl)
$cgmapT :: (forall b. Data b => b -> b) -> AnnFamilyDecl -> AnnFamilyDecl
gmapT :: (forall b. Data b => b -> b) -> AnnFamilyDecl -> AnnFamilyDecl
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnFamilyDecl -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnFamilyDecl -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnFamilyDecl -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnFamilyDecl -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnFamilyDecl -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnFamilyDecl -> m AnnFamilyDecl
Data

instance NoAnn AnnFamilyDecl where
  noAnn :: AnnFamilyDecl
noAnn = [EpToken "("]
-> [EpToken ")"]
-> EpToken "type"
-> EpToken "data"
-> EpToken "family"
-> TokDcolon
-> EpToken "="
-> EpToken "|"
-> EpToken "where"
-> EpToken "{"
-> EpToken ".."
-> EpToken "}"
-> AnnFamilyDecl
AnnFamilyDecl [EpToken "("]
forall a. NoAnn a => a
noAnn [EpToken ")"]
forall a. NoAnn a => a
noAnn EpToken "type"
forall a. NoAnn a => a
noAnn EpToken "data"
forall a. NoAnn a => a
noAnn EpToken "family"
forall a. NoAnn a => a
noAnn TokDcolon
forall a. NoAnn a => a
noAnn EpToken "="
forall a. NoAnn a => a
noAnn EpToken "|"
forall a. NoAnn a => a
noAnn EpToken "where"
forall a. NoAnn a => a
noAnn EpToken "{"
forall a. NoAnn a => a
noAnn EpToken ".."
forall a. NoAnn a => a
noAnn EpToken "}"
forall a. NoAnn a => a
noAnn

------------- Functions over FamilyDecls -----------

familyDeclLName :: FamilyDecl (GhcPass p) -> XRecGhc (IdGhcP p)
familyDeclLName :: forall (p :: Pass). FamilyDecl (GhcPass p) -> XRecGhc (IdGhcP p)
familyDeclLName (FamilyDecl { fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdLName = LIdP (GhcPass p)
n }) = LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n

familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p)
familyDeclName :: forall (p :: Pass). FamilyDecl (GhcPass p) -> IdP (GhcPass p)
familyDeclName = GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> IdGhcP p)
-> (FamilyDecl (GhcPass p)
    -> GenLocated (Anno (IdGhcP p)) (IdGhcP p))
-> FamilyDecl (GhcPass p)
-> IdGhcP p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FamilyDecl (GhcPass p) -> GenLocated (Anno (IdGhcP p)) (IdGhcP p)
forall (p :: Pass). FamilyDecl (GhcPass p) -> XRecGhc (IdGhcP 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)
_) = Maybe (XRec (GhcPass p) (HsType (GhcPass p)))
Maybe (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
forall a. Maybe a
Nothing
famResultKindSignature (KindSig XCKindSig (GhcPass p)
_ XRec (GhcPass p) (HsType (GhcPass p))
ki) = GenLocated SrcSpanAnnA (HsType (GhcPass p))
-> Maybe (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
forall a. a -> Maybe a
Just XRec (GhcPass p) (HsType (GhcPass p))
GenLocated SrcSpanAnnA (HsType (GhcPass p))
ki
famResultKindSignature (TyVarSig XTyVarSig (GhcPass p)
_ LHsTyVarBndr () (GhcPass p)
bndr) =
  case HsTyVarBndr () (GhcPass p) -> HsBndrKind (GhcPass p)
forall flag (pass :: Pass).
HsTyVarBndr flag (GhcPass pass) -> HsBndrKind (GhcPass pass)
hsBndrKind (GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
-> HsTyVarBndr () (GhcPass p)
forall l e. GenLocated l e -> e
unLoc LHsTyVarBndr () (GhcPass p)
GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
bndr) of
    HsBndrNoKind XBndrNoKind (GhcPass p)
_  -> Maybe (XRec (GhcPass p) (HsType (GhcPass p)))
Maybe (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
forall a. Maybe a
Nothing
    HsBndrKind XBndrKind (GhcPass p)
_ XRec (GhcPass p) (HsType (GhcPass p))
ki -> GenLocated SrcSpanAnnA (HsType (GhcPass p))
-> Maybe (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
forall a. a -> Maybe a
Just XRec (GhcPass p) (HsType (GhcPass p))
GenLocated SrcSpanAnnA (HsType (GhcPass p))
ki

-- | Maybe return name of the result type variable
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) = LHsTyVarBndr () (GhcPass a) -> Maybe (IdP (GhcPass a))
forall flag (p :: Pass).
LHsTyVarBndr flag (GhcPass p) -> Maybe (IdP (GhcPass p))
hsLTyVarName LHsTyVarBndr () (GhcPass a)
sig
resultVariableName FamilyResultSig (GhcPass a)
_                = Maybe (IdP (GhcPass a))
Maybe (IdGhcP a)
forall a. Maybe a
Nothing

------------- Pretty printing FamilyDecls -----------

type instance XCInjectivityAnn  (GhcPass _) = TokRarrow
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 EpAnnCO
_ FamilyResultSig (GhcPass p)
result
                  , fdInjectivityAnn :: forall pass. FamilyDecl pass -> Maybe (LInjectivityAnn pass)
fdInjectivityAnn = Maybe (LInjectivityAnn (GhcPass p))
mb_inj })
    = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ FamilyInfo (GhcPass p) -> SDoc
forall pass. FamilyInfo pass -> SDoc
pprFlavour FamilyInfo (GhcPass p)
info SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_top_level SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
             GenLocated (Anno (IdGhcP p)) (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
XRecGhc (IdGhcP p)
-> LHsQTyVars (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pp_vanilla_decl_head LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
ltycon LHsQTyVars (GhcPass p)
tyvars LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
Maybe
  (GenLocated
     SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
forall a. Maybe a
Nothing SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
             SDoc
pp_kind SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_inj SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_where
           , Int -> SDoc -> SDoc
nest Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
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    -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"family"
                       TopLevelFlag
NotTopLevel -> SDoc
forall doc. IsOutput doc => doc
empty

      pp_kind :: SDoc
pp_kind = case FamilyResultSig (GhcPass p)
result of
                  NoSig    XNoSig (GhcPass p)
_         -> SDoc
forall doc. IsOutput doc => doc
empty
                  KindSig  XCKindSig (GhcPass p)
_ LHsKind (GhcPass p)
kind    -> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsKind (GhcPass p)
GenLocated SrcSpanAnnA (HsType (GhcPass p))
kind
                  TyVarSig XTyVarSig (GhcPass p)
_ LHsTyVarBndr () (GhcPass p)
tv_bndr -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"=" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsTyVarBndr () (GhcPass p)
GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass p))
tv_bndr
      pp_inj :: SDoc
pp_inj = case Maybe (LInjectivityAnn (GhcPass p))
mb_inj of
                 Just (L EpAnnCO
_ (InjectivityAnn XCInjectivityAnn (GhcPass p)
_ LIdP (GhcPass p)
lhs [LIdP (GhcPass p)]
rhs)) ->
                   [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ SDoc
forall doc. IsLine doc => doc
vbar, GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
lhs, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"->", [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep ((GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc)
-> [GenLocated (Anno (IdGhcP p)) (IdGhcP p)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LIdP (GhcPass p)]
[GenLocated (Anno (IdGhcP p)) (IdGhcP p)]
rhs) ]
                 Maybe (LInjectivityAnn (GhcPass p))
Nothing -> SDoc
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 ->
          ( String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where"
          , case Maybe [LTyFamInstEqn (GhcPass p)]
mb_eqns of
              Maybe [LTyFamInstEqn (GhcPass p)]
Nothing   -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
".."
              Just [LTyFamInstEqn (GhcPass p)]
eqns -> [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ (GenLocated
   SrcSpanAnnA
   (FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
 -> SDoc)
-> [GenLocated
      SrcSpanAnnA
      (FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (TyFamInstEqn (GhcPass p) -> SDoc
FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
TyFamInstEqn (GhcPass p) -> SDoc
ppr_fam_inst_eqn (FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
 -> SDoc)
-> (GenLocated
      SrcSpanAnnA
      (FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
    -> FamEqn
         (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
-> GenLocated
     SrcSpanAnnA
     (FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated
  SrcSpanAnnA
  (FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
-> FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
forall l e. GenLocated l e -> e
unLoc) [LTyFamInstEqn (GhcPass p)]
[GenLocated
   SrcSpanAnnA
   (FamEqn (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))]
eqns )
        FamilyInfo (GhcPass p)
_ -> (SDoc
forall doc. IsOutput doc => doc
empty, SDoc
forall doc. IsOutput doc => doc
empty)



{- *********************************************************************
*                                                                      *
               Data types and data constructors
*                                                                      *
********************************************************************* -}

type instance XCHsDataDefn    (GhcPass _) = AnnDataDefn
type instance XXHsDataDefn    (GhcPass _) = DataConCantHappen

type instance XCHsDerivingClause    (GhcPass _) = EpToken "deriving"
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 })
    = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"deriving"
           , SDoc
pp_strat_before
           , DerivClauseTys (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr DerivClauseTys (GhcPass p)
dct
           , SDoc
pp_strat_after ]
      where
        -- @via@ is unique in that in comes /after/ the class being derived,
        -- so we must special-case it.
        (SDoc
pp_strat_before, SDoc
pp_strat_after) =
          case Maybe (LDerivStrategy (GhcPass p))
dcs of
            Just (L EpAnnCO
_ via :: DerivStrategy (GhcPass p)
via@ViaStrategy{}) -> (SDoc
forall doc. IsOutput doc => doc
empty, DerivStrategy (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr DerivStrategy (GhcPass p)
via)
            Maybe (LDerivStrategy (GhcPass p))
_                            -> (Maybe (LDerivStrategy (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe (LDerivStrategy (GhcPass p)) -> SDoc
ppDerivStrategy Maybe (LDerivStrategy (GhcPass p))
dcs, SDoc
forall doc. IsOutput doc => doc
empty)

-- | A short description of a @DerivStrategy'@.
derivStrategyName :: DerivStrategy a -> SDoc
derivStrategyName :: forall a. DerivStrategy a -> SDoc
derivStrategyName = String -> SDoc
forall doc. IsLine doc => String -> doc
text (String -> SDoc)
-> (DerivStrategy a -> String) -> DerivStrategy a -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DerivStrategy a -> String
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) = GenLocated SrcSpanAnnA (HsSigType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType (GhcPass p))
ty
  ppr (DctMulti XDctMulti (GhcPass p)
_ [LHsSigType (GhcPass p)]
tys) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens ([GenLocated SrcSpanAnnA (HsSigType (GhcPass p))] -> SDoc
forall a. Outputable a => [a] -> SDoc
interpp'SP [LHsSigType (GhcPass p)]
[GenLocated SrcSpanAnnA (HsSigType (GhcPass p))]
tys)

type instance XStandaloneKindSig GhcPs = (EpToken "type", TokDcolon)
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)
_) = GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
lname

type instance XConDeclGADT GhcPs = AnnConDeclGADT
type instance XConDeclGADT GhcRn = NoExtField
type instance XConDeclGADT GhcTc = NoExtField

type instance XConDeclH98  GhcPs = AnnConDeclH98
type instance XConDeclH98  GhcRn = NoExtField
type instance XConDeclH98  GhcTc = NoExtField

type instance XXConDecl (GhcPass _) = DataConCantHappen

type instance XPrefixConGADT       (GhcPass _) = NoExtField

type instance XRecConGADT          GhcPs = TokRarrow
type instance XRecConGADT          GhcRn = NoExtField
type instance XRecConGADT          GhcTc = NoExtField

type instance XXConDeclGADTDetails (GhcPass _) = DataConCantHappen

data AnnConDeclH98
  = AnnConDeclH98 {
    AnnConDeclH98 -> TokForall
acdh_forall  :: TokForall,
    AnnConDeclH98 -> EpToken "."
acdh_dot :: EpToken ".",
    AnnConDeclH98 -> TokDarrow
acdh_darrow :: TokDarrow
  } deriving Typeable AnnConDeclH98
Typeable AnnConDeclH98 =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnConDeclH98 -> c AnnConDeclH98)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnConDeclH98)
-> (AnnConDeclH98 -> Constr)
-> (AnnConDeclH98 -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnConDeclH98))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnConDeclH98))
-> ((forall b. Data b => b -> b) -> AnnConDeclH98 -> AnnConDeclH98)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r)
-> (forall u. (forall d. Data d => d -> u) -> AnnConDeclH98 -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnConDeclH98 -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98)
-> Data AnnConDeclH98
AnnConDeclH98 -> Constr
AnnConDeclH98 -> DataType
(forall b. Data b => b -> b) -> AnnConDeclH98 -> AnnConDeclH98
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) -> AnnConDeclH98 -> u
forall u. (forall d. Data d => d -> u) -> AnnConDeclH98 -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnConDeclH98
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnConDeclH98 -> c AnnConDeclH98
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnConDeclH98)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnConDeclH98)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnConDeclH98 -> c AnnConDeclH98
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnConDeclH98 -> c AnnConDeclH98
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnConDeclH98
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnConDeclH98
$ctoConstr :: AnnConDeclH98 -> Constr
toConstr :: AnnConDeclH98 -> Constr
$cdataTypeOf :: AnnConDeclH98 -> DataType
dataTypeOf :: AnnConDeclH98 -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnConDeclH98)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnConDeclH98)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnConDeclH98)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnConDeclH98)
$cgmapT :: (forall b. Data b => b -> b) -> AnnConDeclH98 -> AnnConDeclH98
gmapT :: (forall b. Data b => b -> b) -> AnnConDeclH98 -> AnnConDeclH98
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclH98 -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnConDeclH98 -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnConDeclH98 -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnConDeclH98 -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AnnConDeclH98 -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AnnConDeclH98 -> m AnnConDeclH98
Data

instance NoAnn AnnConDeclH98 where
  noAnn :: AnnConDeclH98
noAnn = TokForall -> EpToken "." -> TokDarrow -> AnnConDeclH98
AnnConDeclH98 TokForall
forall a. NoAnn a => a
noAnn EpToken "."
forall a. NoAnn a => a
noAnn TokDarrow
forall a. NoAnn a => a
noAnn

data AnnConDeclGADT
  = AnnConDeclGADT {
    AnnConDeclGADT -> [EpToken "("]
acdg_openp  :: [EpToken "("],
    AnnConDeclGADT -> [EpToken ")"]
acdg_closep :: [EpToken ")"],
    AnnConDeclGADT -> TokDcolon
acdg_dcolon :: TokDcolon
  } deriving Typeable AnnConDeclGADT
Typeable AnnConDeclGADT =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnConDeclGADT -> c AnnConDeclGADT)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnConDeclGADT)
-> (AnnConDeclGADT -> Constr)
-> (AnnConDeclGADT -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnConDeclGADT))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnConDeclGADT))
-> ((forall b. Data b => b -> b)
    -> AnnConDeclGADT -> AnnConDeclGADT)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> AnnConDeclGADT -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnConDeclGADT -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> AnnConDeclGADT -> m AnnConDeclGADT)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnnConDeclGADT -> m AnnConDeclGADT)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnnConDeclGADT -> m AnnConDeclGADT)
-> Data AnnConDeclGADT
AnnConDeclGADT -> Constr
AnnConDeclGADT -> DataType
(forall b. Data b => b -> b) -> AnnConDeclGADT -> AnnConDeclGADT
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) -> AnnConDeclGADT -> u
forall u. (forall d. Data d => d -> u) -> AnnConDeclGADT -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnConDeclGADT
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnConDeclGADT -> c AnnConDeclGADT
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnConDeclGADT)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnConDeclGADT)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnConDeclGADT -> c AnnConDeclGADT
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnConDeclGADT -> c AnnConDeclGADT
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnConDeclGADT
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnConDeclGADT
$ctoConstr :: AnnConDeclGADT -> Constr
toConstr :: AnnConDeclGADT -> Constr
$cdataTypeOf :: AnnConDeclGADT -> DataType
dataTypeOf :: AnnConDeclGADT -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnConDeclGADT)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnConDeclGADT)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnConDeclGADT)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnConDeclGADT)
$cgmapT :: (forall b. Data b => b -> b) -> AnnConDeclGADT -> AnnConDeclGADT
gmapT :: (forall b. Data b => b -> b) -> AnnConDeclGADT -> AnnConDeclGADT
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnConDeclGADT -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnConDeclGADT -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnConDeclGADT -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnnConDeclGADT -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnnConDeclGADT -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnConDeclGADT -> m AnnConDeclGADT
Data

instance NoAnn AnnConDeclGADT where
  noAnn :: AnnConDeclGADT
noAnn = [EpToken "("] -> [EpToken ")"] -> TokDcolon -> AnnConDeclGADT
AnnConDeclGADT [EpToken "("]
forall a. NoAnn a => a
noAnn [EpToken ")"]
forall a. NoAnn a => a
noAnn TokDcolon
forall a. NoAnn a => a
noAnn

-- Codomain could be 'NonEmpty', but at the moment all users need a list.
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
LocatedN SplicePointName
name]
getConNames ConDeclGADT {con_names :: forall pass. ConDecl pass -> NonEmpty (LIdP pass)
con_names = NonEmpty (LIdP GhcRn)
names} = NonEmpty (LocatedN SplicePointName) -> [LocatedN SplicePointName]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (LIdP GhcRn)
NonEmpty (LocatedN SplicePointName)
names

-- | Return @'Just' fields@ if a data constructor declaration uses record
-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors.
-- Otherwise, return 'Nothing'.
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{} -> Maybe (LocatedL [LConDeclField GhcRn])
Maybe (LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
forall a. Maybe a
Nothing
  RecCon XRec GhcRn [LConDeclField GhcRn]
flds -> LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> Maybe (LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
forall a. a -> Maybe a
Just XRec GhcRn [LConDeclField GhcRn]
LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
flds
  InfixCon{}  -> Maybe (LocatedL [LConDeclField GhcRn])
Maybe (LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
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{} -> Maybe (LocatedL [LConDeclField GhcRn])
Maybe (LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
forall a. Maybe a
Nothing
  RecConGADT XRecConGADT GhcRn
_ XRec GhcRn [LConDeclField GhcRn]
flds -> LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)]
-> Maybe (LocatedL [GenLocated SrcSpanAnnA (ConDeclField GhcRn)])
forall a. a -> Maybe a
Just XRec GhcRn [LConDeclField GhcRn]
LocatedL [GenLocated SrcSpanAnnA (ConDeclField 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)) = [XRec (GhcPass p) (HsType (GhcPass p))]
[GenLocated SrcSpanAnnA (HsType (GhcPass p))]
theta

ppDataDefnHeader
 :: (OutputableBndrId p)
 => (Maybe (LHsContext (GhcPass p)) -> SDoc)   -- Printing the header
 -> HsDataDefn (GhcPass p)
 -> SDoc
ppDataDefnHeader :: forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
ppDataDefnHeader 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 SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> NewOrData -> SDoc
forall a. Outputable a => a -> SDoc
ppr (DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
-> NewOrData
forall a. DataDefnCons a -> NewOrData
dataDefnConsNewOrData DataDefnCons (LConDecl (GhcPass p))
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
condecls) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_ct SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe (LHsContext (GhcPass p)) -> SDoc
pp_hdr Maybe (LHsContext (GhcPass p))
context SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_sig
  where
    pp_type :: SDoc
pp_type
      | DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p))) -> Bool
forall a. DataDefnCons a -> Bool
isTypeDataDefnCons DataDefnCons (LConDecl (GhcPass p))
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
condecls = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type"
      | Bool
otherwise = SDoc
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 -> SDoc
forall doc. IsOutput doc => doc
empty
               Just XRec (GhcPass p) CType
ct -> GenLocated SrcSpanAnnP CType -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) CType
GenLocated SrcSpanAnnP CType
ct
    pp_sig :: SDoc
pp_sig = case Maybe (LHsKind (GhcPass p))
mb_sig of
               Maybe (LHsKind (GhcPass p))
Nothing   -> SDoc
forall doc. IsOutput doc => doc
empty
               Just LHsKind (GhcPass p)
kind -> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsKind (GhcPass p)
GenLocated SrcSpanAnnA (HsType (GhcPass p))
kind

pp_data_defn :: (OutputableBndrId p)
                  => (Maybe (LHsContext (GhcPass p)) -> SDoc)   -- Printing the header
                  -> 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 }
  | DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p))) -> Bool
forall a. DataDefnCons a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null DataDefnCons (LConDecl (GhcPass p))
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
condecls
  = (Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
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 SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [GenLocated EpAnnCO (HsDerivingClause (GhcPass p))] -> SDoc
forall a. Outputable a => [a] -> SDoc
pp_derivings HsDeriving (GhcPass p)
[GenLocated EpAnnCO (HsDerivingClause (GhcPass p))]
derivings

  | Bool
otherwise
  = SDoc -> Int -> SDoc -> SDoc
hang ((Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
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 ([LConDecl (GhcPass p)] -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
[LConDecl (GhcPass p)] -> SDoc
pp_condecls (DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
-> [GenLocated SrcSpanAnnA (ConDecl (GhcPass p))]
forall a. DataDefnCons a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList DataDefnCons (LConDecl (GhcPass p))
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
condecls) SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ [GenLocated EpAnnCO (HsDerivingClause (GhcPass p))] -> SDoc
forall a. Outputable a => [a] -> SDoc
pp_derivings HsDeriving (GhcPass p)
[GenLocated EpAnnCO (HsDerivingClause (GhcPass p))]
derivings)
  where
    pp_derivings :: [a] -> SDoc
pp_derivings [a]
ds = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((a -> SDoc) -> [a] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map a -> SDoc
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 = (Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
pp_data_defn (\Maybe (LHsContext (GhcPass p))
_ -> String -> SDoc
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)
    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
v) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"::" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsSigType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType (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
  | [GenLocated SrcSpanAnnA (ConDecl (GhcPass p))] -> Bool
forall (f :: * -> *) l pass.
Foldable f =>
f (GenLocated l (ConDecl pass)) -> Bool
anyLConIsGadt [LConDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (ConDecl (GhcPass p))]
cs             -- In GADT syntax
  = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where") Int
2 ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((GenLocated SrcSpanAnnA (ConDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (ConDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (ConDecl (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LConDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (ConDecl (GhcPass p))]
cs))
  | Bool
otherwise                    -- In H98 syntax
  = SDoc
forall doc. IsLine doc => doc
equals SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
" |") ((GenLocated SrcSpanAnnA (ConDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (ConDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (ConDecl (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LConDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (ConDecl (GhcPass p))]
cs))

instance (OutputableBndrId p) => Outputable (ConDecl (GhcPass p)) where
    ppr :: ConDecl (GhcPass p) -> SDoc
ppr = ConDecl (GhcPass p) -> SDoc
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 })
  = Maybe (LHsDoc (GhcPass p)) -> SDoc -> SDoc
forall name. Maybe (LHsDoc name) -> SDoc -> SDoc
pprMaybeWithDoc Maybe (LHsDoc (GhcPass p))
doc (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
    [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ HsForAllTelescope (GhcPass p)
-> Maybe (LHsContext (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsForAllTelescope (GhcPass p)
-> Maybe (LHsContext (GhcPass p)) -> SDoc
pprHsForAll (EpAnnForallInvis
-> [LHsTyVarBndr Specificity (GhcPass p)]
-> HsForAllTelescope (GhcPass p)
forall (p :: Pass).
EpAnnForallInvis
-> [LHsTyVarBndr Specificity (GhcPass p)]
-> HsForAllTelescope (GhcPass p)
mkHsForAllInvisTele EpAnnForallInvis
forall a. NoAnn a => 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)
HsConDetails
  Void
  (HsScaled
     (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p))))
  (GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))])
args ]
  where
    -- In ppr_details: let's not print the multiplicities (they are always 1, by
    -- definition) as they do not appear in an actual declaration.
    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) = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
-> GenLocated SrcSpanAnnA (HsType (GhcPass p))
forall pass a. HsScaled pass a -> a
hsScaledThing HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
t1),
                                         IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprInfixOcc IdGhcP p
con,
                                         GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
-> GenLocated SrcSpanAnnA (HsType (GhcPass p))
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) = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep (IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
con
                                    SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: (HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
 -> SDoc)
-> [HsScaled
      (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (HsType (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsType (GhcPass p) -> SDoc
pprHsType (HsType (GhcPass p) -> SDoc)
-> (HsScaled
      (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
    -> HsType (GhcPass p))
-> HsScaled
     (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> HsType (GhcPass p)
forall l e. GenLocated l e -> e
unLoc (GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> HsType (GhcPass p))
-> (HsScaled
      (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
    -> GenLocated SrcSpanAnnA (HsType (GhcPass p)))
-> HsScaled
     (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
-> HsType (GhcPass p)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
-> GenLocated SrcSpanAnnA (HsType (GhcPass p))
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)  = IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IdGhcP p
con
                                 SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [LConDeclField (GhcPass p)] -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
[LConDeclField (GhcPass p)] -> SDoc
pprConDeclFields (GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))]
-> [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))]
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 })
  = Maybe (LHsDoc (GhcPass p)) -> SDoc -> SDoc
forall name. Maybe (LHsDoc name) -> SDoc -> SDoc
pprMaybeWithDoc Maybe (LHsDoc (GhcPass p))
doc (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [GenLocated (Anno (IdGhcP p)) (IdGhcP p)] -> SDoc
forall a l. OutputableBndr a => [GenLocated l a] -> SDoc
ppr_con_names (NonEmpty (GenLocated (Anno (IdGhcP p)) (IdGhcP p))
-> [GenLocated (Anno (IdGhcP p)) (IdGhcP p)]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (LIdP (GhcPass p))
NonEmpty (GenLocated (Anno (IdGhcP p)) (IdGhcP p))
cons) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon
    SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [HsOuterSigTyVarBndrs (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsOuterSigTyVarBndrs (GhcPass p) -> SDoc
pprHsOuterSigTyVarBndrs HsOuterSigTyVarBndrs (GhcPass p)
outer_bndrs SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe (LHsContext (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe (LHsContext (GhcPass p)) -> SDoc
pprLHsContext Maybe (LHsContext (GhcPass p))
mcxt,
              [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep (HsConDeclGADTDetails (GhcPass p) -> [SDoc]
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 [SDoc] -> [SDoc] -> [SDoc]
forall a. [a] -> [a] -> [a]
++ [GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
GenLocated SrcSpanAnnA (HsType (GhcPass p))
res_ty]) ])
  where
    ppr_args :: HsConDeclGADTDetails (GhcPass p) -> [SDoc]
ppr_args (PrefixConGADT XPrefixConGADT (GhcPass p)
_ [HsScaled (GhcPass p) (LBangType (GhcPass p))]
args) = (HsScaled (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
 -> SDoc)
-> [HsScaled
      (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
-> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (\(HsScaled HsArrow (GhcPass p)
arr GenLocated SrcSpanAnnA (HsType (GhcPass p))
t) -> GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr GenLocated SrcSpanAnnA (HsType (GhcPass p))
t SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsArrowOf (GenLocated SrcSpanAnnA (HsType (GhcPass p))) (GhcPass p)
-> SDoc
forall {pass :: Pass} {mult}.
(OutputableBndr (IdGhcP pass),
 OutputableBndr (IdGhcP (NoGhcTcPass pass)), IsPass pass,
 Outputable mult,
 Outputable (GenLocated (Anno (IdGhcP pass)) (IdGhcP pass)),
 Outputable
   (GenLocated
      (Anno (IdGhcP (NoGhcTcPass pass))) (IdGhcP (NoGhcTcPass pass)))) =>
HsArrowOf mult (GhcPass pass) -> SDoc
ppr_arr HsArrow (GhcPass p)
HsArrowOf (GenLocated SrcSpanAnnA (HsType (GhcPass p))) (GhcPass p)
arr) [HsScaled (GhcPass p) (LBangType (GhcPass p))]
[HsScaled
   (GhcPass p) (GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
args
    ppr_args (RecConGADT XRecConGADT (GhcPass p)
_ XRec (GhcPass p) [LConDeclField (GhcPass p)]
fields) = [[LConDeclField (GhcPass p)] -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
[LConDeclField (GhcPass p)] -> SDoc
pprConDeclFields (GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))]
-> [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))]
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) [LConDeclField (GhcPass p)]
GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField (GhcPass p))]
fields) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
arrow]

    -- Display linear arrows as unrestricted with -XNoLinearTypes
    -- (cf. dataConDisplayType in Note [Displaying linear fields] in GHC.Core.DataCon)
    ppr_arr :: HsArrowOf mult (GhcPass pass) -> SDoc
ppr_arr (HsLinearArrow XLinearArrow mult (GhcPass pass)
_) = (SDocContext -> Bool) -> (Bool -> SDoc) -> SDoc
forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocLinearTypes ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \Bool
show_linear_types ->
                                  if Bool
show_linear_types then SDoc
lollipop else SDoc
arrow
    ppr_arr HsArrowOf mult (GhcPass pass)
arr = HsArrowOf mult (GhcPass pass) -> SDoc
forall mult (pass :: Pass).
(Outputable mult, OutputableBndrId pass) =>
HsArrowOf mult (GhcPass pass) -> SDoc
pprHsArrow HsArrowOf mult (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 = (GenLocated l a -> SDoc) -> [GenLocated l a] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (a -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (a -> SDoc) -> (GenLocated l a -> a) -> GenLocated l a -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated l a -> a
forall l e. GenLocated l e -> e
unLoc)

{-
************************************************************************
*                                                                      *
                Instance declarations
*                                                                      *
************************************************************************
-}

type instance XCFamEqn    (GhcPass _) r = ([EpToken "("], [EpToken ")"], EpToken "=")
type instance XXFamEqn    (GhcPass _) r = DataConCantHappen

----------------- Class instances -------------

type instance XCClsInstDecl    GhcPs = ( Maybe (LWarningTxt GhcPs)
                                             -- The warning of the deprecated instance
                                             -- See Note [Implementation of deprecated instances]
                                             -- in GHC.Tc.Solver.Dict
                                       , AnnClsInstDecl
                                       , AnnSortKey DeclTag) -- For sorting the additional annotations
                                        -- TODO:AZ:tidy up
type instance XCClsInstDecl    GhcRn = Maybe (LWarningTxt GhcRn)
                                           -- The warning of the deprecated instance
                                           -- See Note [Implementation of deprecated instances]
                                           -- in GHC.Tc.Solver.Dict
type instance XCClsInstDecl    GhcTc = NoExtField

type instance XXClsInstDecl    (GhcPass _) = DataConCantHappen

----------------- Instances of all kinds -------------

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

data AnnClsInstDecl
  = AnnClsInstDecl {
    AnnClsInstDecl -> EpToken "instance"
acid_instance :: EpToken "instance",
    AnnClsInstDecl -> EpToken "where"
acid_where    :: EpToken "where",
    AnnClsInstDecl -> EpToken "{"
acid_openc    :: EpToken "{",
    AnnClsInstDecl -> [EpToken ";"]
acid_semis    :: [EpToken ";"],
    AnnClsInstDecl -> EpToken "}"
acid_closec   :: EpToken "}"
  } deriving Typeable AnnClsInstDecl
Typeable AnnClsInstDecl =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> AnnClsInstDecl -> c AnnClsInstDecl)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AnnClsInstDecl)
-> (AnnClsInstDecl -> Constr)
-> (AnnClsInstDecl -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AnnClsInstDecl))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AnnClsInstDecl))
-> ((forall b. Data b => b -> b)
    -> AnnClsInstDecl -> AnnClsInstDecl)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> AnnClsInstDecl -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AnnClsInstDecl -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> AnnClsInstDecl -> m AnnClsInstDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnnClsInstDecl -> m AnnClsInstDecl)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AnnClsInstDecl -> m AnnClsInstDecl)
-> Data AnnClsInstDecl
AnnClsInstDecl -> Constr
AnnClsInstDecl -> DataType
(forall b. Data b => b -> b) -> AnnClsInstDecl -> AnnClsInstDecl
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) -> AnnClsInstDecl -> u
forall u. (forall d. Data d => d -> u) -> AnnClsInstDecl -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnClsInstDecl
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnClsInstDecl -> c AnnClsInstDecl
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnClsInstDecl)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnClsInstDecl)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnClsInstDecl -> c AnnClsInstDecl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AnnClsInstDecl -> c AnnClsInstDecl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnClsInstDecl
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AnnClsInstDecl
$ctoConstr :: AnnClsInstDecl -> Constr
toConstr :: AnnClsInstDecl -> Constr
$cdataTypeOf :: AnnClsInstDecl -> DataType
dataTypeOf :: AnnClsInstDecl -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnClsInstDecl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AnnClsInstDecl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnClsInstDecl)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AnnClsInstDecl)
$cgmapT :: (forall b. Data b => b -> b) -> AnnClsInstDecl -> AnnClsInstDecl
gmapT :: (forall b. Data b => b -> b) -> AnnClsInstDecl -> AnnClsInstDecl
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AnnClsInstDecl -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AnnClsInstDecl -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AnnClsInstDecl -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnnClsInstDecl -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AnnClsInstDecl -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AnnClsInstDecl -> m AnnClsInstDecl
Data

instance NoAnn AnnClsInstDecl where
  noAnn :: AnnClsInstDecl
noAnn = EpToken "instance"
-> EpToken "where"
-> EpToken "{"
-> [EpToken ";"]
-> EpToken "}"
-> AnnClsInstDecl
AnnClsInstDecl EpToken "instance"
forall a. NoAnn a => a
noAnn EpToken "where"
forall a. NoAnn a => a
noAnn EpToken "{"
forall a. NoAnn a => a
noAnn [EpToken ";"]
forall a. NoAnn a => a
noAnn EpToken "}"
forall a. NoAnn a => a
noAnn

cidDeprecation :: forall p. IsPass p
               => ClsInstDecl (GhcPass p)
               -> Maybe (WarningTxt (GhcPass p))
cidDeprecation :: forall (p :: Pass).
IsPass p =>
ClsInstDecl (GhcPass p) -> Maybe (WarningTxt (GhcPass p))
cidDeprecation = (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p))
 -> WarningTxt (GhcPass p))
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
-> Maybe (WarningTxt (GhcPass p))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GenLocated SrcSpanAnnP (WarningTxt (GhcPass p))
-> WarningTxt (GhcPass p)
forall l e. GenLocated l e -> e
unLoc (Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
 -> Maybe (WarningTxt (GhcPass p)))
-> (ClsInstDecl (GhcPass p)
    -> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p))))
-> ClsInstDecl (GhcPass p)
-> Maybe (WarningTxt (GhcPass p))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GhcPass p
-> ClsInstDecl (GhcPass p)
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
decl_deprecation (forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p)
  where
    decl_deprecation :: GhcPass p  -> ClsInstDecl (GhcPass p)
                     -> Maybe (LocatedP (WarningTxt (GhcPass p)))
    decl_deprecation :: GhcPass p
-> ClsInstDecl (GhcPass p)
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
decl_deprecation GhcPass p
GhcPs (ClsInstDecl{ cid_ext :: forall pass. ClsInstDecl pass -> XCClsInstDecl pass
cid_ext = (Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
depr, AnnClsInstDecl
_, AnnSortKey DeclTag
_) } )
      = Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
depr
    decl_deprecation GhcPass p
GhcRn (ClsInstDecl{ cid_ext :: forall pass. ClsInstDecl pass -> XCClsInstDecl pass
cid_ext = XCClsInstDecl (GhcPass p)
depr })
      = Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
XCClsInstDecl (GhcPass p)
depr
    decl_deprecation GhcPass p
_ ClsInstDecl (GhcPass p)
_ = Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
forall a. Maybe a
Nothing

instance OutputableBndrId p
       => Outputable (TyFamInstDecl (GhcPass p)) where
  ppr :: TyFamInstDecl (GhcPass p) -> SDoc
ppr = TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
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 })
   = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> TopLevelFlag -> SDoc
ppr_instance_keyword TopLevelFlag
top_lvl SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> TyFamInstEqn (GhcPass p) -> SDoc
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    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"instance"
ppr_instance_keyword TopLevelFlag
NotTopLevel = SDoc
forall doc. IsOutput doc => doc
empty

pprTyFamDefltDecl :: (OutputableBndrId p)
                  => TyFamDefltDecl (GhcPass p) -> SDoc
pprTyFamDefltDecl :: forall (p :: Pass).
OutputableBndrId p =>
TyFamDefltDecl (GhcPass p) -> SDoc
pprTyFamDefltDecl = TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
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 -> HsFamEqnPats pass
feqn_pats   = HsFamEqnPats (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 })
    = IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsFamEqnPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsFamEqnPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pprHsFamInstLHS IdP (GhcPass p)
IdGhcP p
tycon HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs HsFamEqnPats (GhcPass p)
pats LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
Maybe
  (GenLocated
     SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
forall a. Maybe a
Nothing SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
forall doc. IsLine doc => doc
equals SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
GenLocated SrcSpanAnnA (HsType (GhcPass p))
rhs

instance OutputableBndrId p
       => Outputable (DataFamInstDecl (GhcPass p)) where
  ppr :: DataFamInstDecl (GhcPass p) -> SDoc
ppr = TopLevelFlag -> DataFamInstDecl (GhcPass p) -> SDoc
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 -> HsFamEqnPats pass
feqn_pats   = HsFamEqnPats (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 })})
  = (Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
(Maybe (LHsContext (GhcPass p)) -> SDoc)
-> HsDataDefn (GhcPass p) -> SDoc
pp_data_defn Maybe (LHsContext (GhcPass p)) -> SDoc
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
              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsFamEqnPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
forall (p :: Pass).
OutputableBndrId p =>
IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsFamEqnPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pprHsFamInstLHS IdP (GhcPass p)
IdGhcP p
tycon HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs HsFamEqnPats (GhcPass p)
pats LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
Maybe
  (GenLocated
     SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType (GhcPass p))])
mctxt
                  -- pp_data_defn pretty-prints the kind sig. See #14817.

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 }}}
  = NewOrData -> SDoc
forall a. Outputable a => a -> SDoc
ppr (DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
-> NewOrData
forall a. DataDefnCons a -> NewOrData
dataDefnConsNewOrData DataDefnCons (LConDecl (GhcPass p))
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl (GhcPass p)))
cons)

pprHsFamInstLHS :: (OutputableBndrId p)
   => IdP (GhcPass p)
   -> HsOuterFamEqnTyVarBndrs (GhcPass p)
   -> HsFamEqnPats (GhcPass p)
   -> LexicalFixity
   -> Maybe (LHsContext (GhcPass p))
   -> SDoc
pprHsFamInstLHS :: forall (p :: Pass).
OutputableBndrId p =>
IdP (GhcPass p)
-> HsOuterFamEqnTyVarBndrs (GhcPass p)
-> HsFamEqnPats (GhcPass p)
-> LexicalFixity
-> Maybe (LHsContext (GhcPass p))
-> SDoc
pprHsFamInstLHS IdP (GhcPass p)
thing HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs HsFamEqnPats (GhcPass p)
typats LexicalFixity
fixity Maybe (LHsContext (GhcPass p))
mb_ctxt
   = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ HsOuterFamEqnTyVarBndrs (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsOuterFamEqnTyVarBndrs (GhcPass p) -> SDoc
pprHsOuterFamEqnTyVarBndrs HsOuterFamEqnTyVarBndrs (GhcPass p)
bndrs
          , Maybe (LHsContext (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe (LHsContext (GhcPass p)) -> SDoc
pprLHsContext Maybe (LHsContext (GhcPass p))
mb_ctxt
          , IdGhcP p
-> LexicalFixity
-> [HsArg
      (GhcPass p)
      (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
      (GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
-> SDoc
forall id tm ty (p :: Pass).
(OutputableBndr id, Outputable tm, Outputable ty) =>
id -> LexicalFixity -> [HsArg (GhcPass p) tm ty] -> SDoc
pprHsArgsApp IdP (GhcPass p)
IdGhcP p
thing LexicalFixity
fixity HsFamEqnPats (GhcPass p)
[HsArg
   (GhcPass p)
   (GenLocated SrcSpanAnnA (HsType (GhcPass p)))
   (GenLocated SrcSpanAnnA (HsType (GhcPass p)))]
typats ]

instance OutputableBndrId p
       => Outputable (ClsInstDecl (GhcPass p)) where
    ppr :: ClsInstDecl (GhcPass p) -> SDoc
ppr (cid :: ClsInstDecl (GhcPass p)
cid@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 })
      | [GenLocated SrcSpanAnnA (Sig (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LSig (GhcPass p)]
[GenLocated SrcSpanAnnA (Sig (GhcPass p))]
sigs, [GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LTyFamInstDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))]
ats, [GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LDataFamInstDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))]
adts, [GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null LHsBinds (GhcPass p)
[GenLocated SrcSpanAnnA (HsBindLR (GhcPass p) (GhcPass p))]
binds  -- No "where" part
      = SDoc
top_matter

      | Bool
otherwise       -- Laid out
      = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
top_matter SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where"
             , Int -> SDoc -> SDoc
nest Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
pprDeclList ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$
               (GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> TyFamInstDecl (GhcPass p) -> SDoc
pprTyFamInstDecl TopLevelFlag
NotTopLevel (TyFamInstDecl (GhcPass p) -> SDoc)
-> (GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))
    -> TyFamInstDecl (GhcPass p))
-> GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))
-> TyFamInstDecl (GhcPass p)
forall l e. GenLocated l e -> e
unLoc)   [LTyFamInstDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (TyFamInstDecl (GhcPass p))]
ats [SDoc] -> [SDoc] -> [SDoc]
forall a. [a] -> [a] -> [a]
++
               (GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (TopLevelFlag -> DataFamInstDecl (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
TopLevelFlag -> DataFamInstDecl (GhcPass p) -> SDoc
pprDataFamInstDecl TopLevelFlag
NotTopLevel (DataFamInstDecl (GhcPass p) -> SDoc)
-> (GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))
    -> DataFamInstDecl (GhcPass p))
-> GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))
-> DataFamInstDecl (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [LDataFamInstDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))]
adts [SDoc] -> [SDoc] -> [SDoc]
forall a. [a] -> [a] -> [a]
++
               LHsBinds (GhcPass p) -> [LSig (GhcPass p)] -> [SDoc]
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 = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"instance" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
-> (WarningTxt (GhcPass p) -> SDoc)
-> Maybe (WarningTxt (GhcPass p))
-> SDoc
forall b a. b -> (a -> b) -> Maybe a -> b
maybe SDoc
forall doc. IsOutput doc => doc
empty WarningTxt (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (ClsInstDecl (GhcPass p) -> Maybe (WarningTxt (GhcPass p))
forall (p :: Pass).
IsPass p =>
ClsInstDecl (GhcPass p) -> Maybe (WarningTxt (GhcPass p))
cidDeprecation ClsInstDecl (GhcPass p)
cid)
                                     SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe (LocatedP OverlapMode) -> SDoc
ppOverlapPragma Maybe (XRec (GhcPass p) OverlapMode)
Maybe (LocatedP OverlapMode)
mbOverlap
                                     SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsSigType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType (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       -> SDoc
forall doc. IsOutput doc => doc
empty
    Just (L EpAnnCO
_ DerivStrategy (GhcPass p)
ds) -> DerivStrategy (GhcPass p) -> SDoc
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           -> SDoc
forall doc. IsOutput doc => doc
empty
    Just (L SrcSpanAnnP
_ (NoOverlap SourceText
s))    -> SourceText -> String -> SDoc
forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# NO_OVERLAP #-}"
    Just (L SrcSpanAnnP
_ (Overlappable SourceText
s)) -> SourceText -> String -> SDoc
forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# OVERLAPPABLE #-}"
    Just (L SrcSpanAnnP
_ (Overlapping SourceText
s))  -> SourceText -> String -> SDoc
forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# OVERLAPPING #-}"
    Just (L SrcSpanAnnP
_ (Overlaps SourceText
s))     -> SourceText -> String -> SDoc
forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# OVERLAPS #-}"
    Just (L SrcSpanAnnP
_ (Incoherent SourceText
s))   -> SourceText -> String -> SDoc
forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# INCOHERENT #-}"
    Just (L SrcSpanAnnP
_ (NonCanonical SourceText
s)) -> SourceText -> String -> SDoc
forall {doc}. IsLine doc => SourceText -> String -> doc
maybe_stext SourceText
s String
"{-# INCOHERENT #-}" -- No surface syntax for NONCANONICAL yet
  where
    maybe_stext :: SourceText -> String -> doc
maybe_stext SourceText
NoSourceText     String
alt = String -> doc
forall doc. IsLine doc => String -> doc
text String
alt
    maybe_stext (SourceText FastString
src) String
_   = FastString -> doc
forall doc. IsLine doc => FastString -> doc
ftext FastString
src doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> 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 }) = ClsInstDecl (GhcPass p) -> SDoc
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 }) = TyFamInstDecl (GhcPass p) -> SDoc
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 }) = DataFamInstDecl (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr DataFamInstDecl (GhcPass p)
decl

-- Extract the declarations of associated data types from an instance

instDeclDataFamInsts :: [LInstDecl (GhcPass p)] -> [DataFamInstDecl (GhcPass p)]
instDeclDataFamInsts :: forall (p :: Pass).
[LInstDecl (GhcPass p)] -> [DataFamInstDecl (GhcPass p)]
instDeclDataFamInsts [LInstDecl (GhcPass p)]
inst_decls
  = (GenLocated SrcSpanAnnA (InstDecl (GhcPass p))
 -> [DataFamInstDecl (GhcPass p)])
-> [GenLocated SrcSpanAnnA (InstDecl (GhcPass p))]
-> [DataFamInstDecl (GhcPass p)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap LInstDecl (GhcPass p) -> [DataFamInstDecl (GhcPass p)]
GenLocated SrcSpanAnnA (InstDecl (GhcPass p))
-> [DataFamInstDecl (GhcPass p)]
forall (p :: Pass).
LInstDecl (GhcPass p) -> [DataFamInstDecl (GhcPass p)]
do_one [LInstDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (InstDecl (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 } }))
      = (GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))
 -> DataFamInstDecl (GhcPass p))
-> [GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))]
-> [DataFamInstDecl (GhcPass p)]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (DataFamInstDecl (GhcPass p))
-> DataFamInstDecl (GhcPass p)
forall l e. GenLocated l e -> e
unLoc [LDataFamInstDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (DataFamInstDecl (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 {}))                              = []

-- | Convert a 'NewOrData' to a 'TyConFlavour'
newOrDataToFlavour :: NewOrData -> TyConFlavour tc
newOrDataToFlavour :: forall tc. NewOrData -> TyConFlavour tc
newOrDataToFlavour NewOrData
NewType  = TyConFlavour tc
forall tc. TyConFlavour tc
NewtypeFlavour
newOrDataToFlavour NewOrData
DataType = TyConFlavour tc
forall tc. TyConFlavour tc
DataTypeFlavour

instance Outputable NewOrData where
  ppr :: NewOrData -> SDoc
ppr NewOrData
NewType  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"newtype"
  ppr NewOrData
DataType = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"data"

-- At the moment we only call this with @f = '[]'@ and @f = 'DataDefnCons'@.
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 f (GenLocated l (ConDecl pass)) -> [GenLocated l (ConDecl pass)]
forall a. f a -> [a]
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 #-}

{-
************************************************************************
*                                                                      *
\subsection[DerivDecl]{A stand-alone instance deriving declaration}
*                                                                      *
************************************************************************
-}

type instance XCDerivDecl    GhcPs = ( Maybe (LWarningTxt GhcPs)
                                           -- The warning of the deprecated derivation
                                           -- See Note [Implementation of deprecated instances]
                                           -- in GHC.Tc.Solver.Dict
                                     , AnnDerivDecl )
type instance XCDerivDecl    GhcRn = ( Maybe (LWarningTxt GhcRn)
                                           -- The warning of the deprecated derivation
                                           -- See Note [Implementation of deprecated instances]
                                           -- in GHC.Tc.Solver.Dict
                                     , AnnDerivDecl )
type instance XCDerivDecl    GhcTc = AnnDerivDecl
type instance XXDerivDecl    (GhcPass _) = DataConCantHappen

type AnnDerivDecl = (EpToken "deriving", EpToken "instance")

derivDeprecation :: forall p. IsPass p
               => DerivDecl (GhcPass p)
               -> Maybe (WarningTxt (GhcPass p))
derivDeprecation :: forall (p :: Pass).
IsPass p =>
DerivDecl (GhcPass p) -> Maybe (WarningTxt (GhcPass p))
derivDeprecation = (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p))
 -> WarningTxt (GhcPass p))
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
-> Maybe (WarningTxt (GhcPass p))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GenLocated SrcSpanAnnP (WarningTxt (GhcPass p))
-> WarningTxt (GhcPass p)
forall l e. GenLocated l e -> e
unLoc (Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
 -> Maybe (WarningTxt (GhcPass p)))
-> (DerivDecl (GhcPass p)
    -> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p))))
-> DerivDecl (GhcPass p)
-> Maybe (WarningTxt (GhcPass p))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GhcPass p
-> DerivDecl (GhcPass p)
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
decl_deprecation (forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p)
  where
    decl_deprecation :: GhcPass p  -> DerivDecl (GhcPass p)
                     -> Maybe (LocatedP (WarningTxt (GhcPass p)))
    decl_deprecation :: GhcPass p
-> DerivDecl (GhcPass p)
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
decl_deprecation GhcPass p
GhcPs (DerivDecl{ deriv_ext :: forall pass. DerivDecl pass -> XCDerivDecl pass
deriv_ext = (Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
depr, AnnDerivDecl
_) })
      = Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
depr
    decl_deprecation GhcPass p
GhcRn (DerivDecl{ deriv_ext :: forall pass. DerivDecl pass -> XCDerivDecl pass
deriv_ext = (Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
depr, AnnDerivDecl
_) })
      = Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
depr
    decl_deprecation GhcPass p
_ DerivDecl (GhcPass p)
_ = Maybe (GenLocated SrcSpanAnnP (WarningTxt (GhcPass p)))
forall a. Maybe a
Nothing

instance OutputableBndrId p
       => Outputable (DerivDecl (GhcPass p)) where
    ppr :: DerivDecl (GhcPass p) -> SDoc
ppr (deriv :: DerivDecl (GhcPass p)
deriv@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 })
        = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"deriving"
               , Maybe (LDerivStrategy (GhcPass p)) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
Maybe (LDerivStrategy (GhcPass p)) -> SDoc
ppDerivStrategy Maybe (LDerivStrategy (GhcPass p))
ds
               , String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"instance"
               , SDoc
-> (WarningTxt (GhcPass p) -> SDoc)
-> Maybe (WarningTxt (GhcPass p))
-> SDoc
forall b a. b -> (a -> b) -> Maybe a -> b
maybe SDoc
forall doc. IsOutput doc => doc
empty WarningTxt (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr (DerivDecl (GhcPass p) -> Maybe (WarningTxt (GhcPass p))
forall (p :: Pass).
IsPass p =>
DerivDecl (GhcPass p) -> Maybe (WarningTxt (GhcPass p))
derivDeprecation DerivDecl (GhcPass p)
deriv)
               , Maybe (LocatedP OverlapMode) -> SDoc
ppOverlapPragma Maybe (XRec (GhcPass p) OverlapMode)
Maybe (LocatedP OverlapMode)
o
               , HsWildCardBndrs
  (GhcPass p) (GenLocated SrcSpanAnnA (HsSigType (GhcPass p)))
-> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigWcType (GhcPass p)
HsWildCardBndrs
  (GhcPass p) (GenLocated SrcSpanAnnA (HsSigType (GhcPass p)))
ty ]

{-
************************************************************************
*                                                                      *
                Deriving strategies
*                                                                      *
************************************************************************
-}

type instance XStockStrategy    GhcPs = EpToken "stock"
type instance XStockStrategy    GhcRn = NoExtField
type instance XStockStrategy    GhcTc = NoExtField

type instance XAnyClassStrategy GhcPs = EpToken "anyclass"
type instance XAnyClassStrategy GhcRn = NoExtField
type instance XAnyClassStrategy GhcTc = NoExtField

type instance XNewtypeStrategy  GhcPs = EpToken "newtype"
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 (EpToken "via") (LHsSigType GhcPs)

instance OutputableBndrId p
        => Outputable (DerivStrategy (GhcPass p)) where
    ppr :: DerivStrategy (GhcPass p) -> SDoc
ppr (StockStrategy    XStockStrategy (GhcPass p)
_) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"stock"
    ppr (AnyclassStrategy XAnyClassStrategy (GhcPass p)
_) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"anyclass"
    ppr (NewtypeStrategy  XNewtypeStrategy (GhcPass p)
_) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"newtype"
    ppr (ViaStrategy XViaStrategy (GhcPass p)
ty)     = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"via" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
                                                GhcPass p
GhcPs -> XViaStrategyPs -> SDoc
forall a. Outputable a => a -> SDoc
ppr XViaStrategy (GhcPass p)
XViaStrategyPs
ty
                                                GhcPass p
GhcRn -> GenLocated SrcSpanAnnA (HsSigType GhcRn) -> SDoc
forall a. Outputable a => a -> SDoc
ppr XViaStrategy (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType GhcRn)
ty
                                                GhcPass p
GhcTc -> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr XViaStrategy (GhcPass p)
Type
ty

instance Outputable XViaStrategyPs where
    ppr :: XViaStrategyPs -> SDoc
ppr (XViaStrategyPs EpToken "via"
_ LHsSigType GhcPs
t) = GenLocated SrcSpanAnnA (HsSigType GhcPs) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
t


-- | Eliminate a 'DerivStrategy'.
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

-- | Map over the @via@ type if dealing with 'ViaStrategy'. Otherwise,
-- return the 'DerivStrategy' unchanged.
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 = DerivStrategy p
-> (XViaStrategy p -> DerivStrategy p)
-> DerivStrategy p
-> DerivStrategy p
forall p (pass :: Pass) r.
(p ~ GhcPass pass) =>
r -> (XViaStrategy p -> r) -> DerivStrategy p -> r
foldDerivStrategy DerivStrategy p
ds (XViaStrategy p -> DerivStrategy p
XViaStrategy (GhcPass pass) -> DerivStrategy p
forall pass. XViaStrategy pass -> DerivStrategy pass
ViaStrategy (XViaStrategy (GhcPass pass) -> DerivStrategy p)
-> (XViaStrategy (GhcPass pass) -> XViaStrategy (GhcPass pass))
-> XViaStrategy (GhcPass pass)
-> DerivStrategy p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XViaStrategy p -> XViaStrategy p
XViaStrategy (GhcPass pass) -> XViaStrategy (GhcPass pass)
f) DerivStrategy p
ds

{-
************************************************************************
*                                                                      *
\subsection[DefaultDecl]{A @default@ declaration}
*                                                                      *
************************************************************************
-}

type instance XCDefaultDecl    GhcPs = (EpToken "default", EpToken "(", EpToken ")")
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)
_ Maybe (LIdP (GhcPass p))
cl [LHsType (GhcPass p)]
tys)
      = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"default" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SDoc -> SDoc)
-> (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc -> SDoc)
-> Maybe (GenLocated (Anno (IdGhcP p)) (IdGhcP p))
-> SDoc
-> SDoc
forall b a. b -> (a -> b) -> Maybe a -> b
maybe SDoc -> SDoc
forall a. a -> a
id (SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
(<+>) (SDoc -> SDoc -> SDoc)
-> (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc)
-> GenLocated (Anno (IdGhcP p)) (IdGhcP p)
-> SDoc
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr) Maybe (LIdP (GhcPass p))
Maybe (GenLocated (Anno (IdGhcP p)) (IdGhcP p))
cl (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens ([GenLocated SrcSpanAnnA (HsType (GhcPass p))] -> SDoc
forall a. Outputable a => [a] -> SDoc
interpp'SP [LHsType (GhcPass p)]
[GenLocated SrcSpanAnnA (HsType (GhcPass p))]
tys))

{-
************************************************************************
*                                                                      *
\subsection{Foreign function interface declaration}
*                                                                      *
************************************************************************
-}

type instance XForeignImport   GhcPs = (EpToken "foreign", EpToken "import", TokDcolon)
type instance XForeignImport   GhcRn = NoExtField
type instance XForeignImport   GhcTc = Coercion

type instance XForeignExport   GhcPs = (EpToken "foreign", EpToken "export", TokDcolon)
type instance XForeignExport   GhcRn = NoExtField
type instance XForeignExport   GhcTc = Coercion

type instance XXForeignDecl    (GhcPass _) = DataConCantHappen

type instance XCImport (GhcPass _) = LocatedE SourceText -- original source text for the C entity
type instance XXForeignImport  (GhcPass _) = DataConCantHappen

type instance XCExport (GhcPass _) = LocatedE SourceText -- original source text for the C entity
type instance XXForeignExport  (GhcPass _) = DataConCantHappen


-- pretty printing of foreign declarations

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 (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"foreign import" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> ForeignImport (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ForeignImport (GhcPass p)
fimport SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n)
         Int
2 (SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsSigType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType (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 (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"foreign export" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> ForeignExport (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr ForeignExport (GhcPass p)
fexport SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
n)
       Int
2 (SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated SrcSpanAnnA (HsSigType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType (GhcPass p))
ty)

instance OutputableBndrId p
       => Outputable (ForeignImport (GhcPass p)) where
  ppr :: ForeignImport (GhcPass p) -> SDoc
ppr (CImport (L EpaLocation
_ SourceText
srcText) XRec (GhcPass p) CCallConv
cconv XRec (GhcPass p) Safety
safety Maybe Header
mHeader CImportSpec
spec) =
    GenLocated EpaLocation CCallConv -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) CCallConv
GenLocated EpaLocation CCallConv
cconv SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> GenLocated EpaLocation Safety -> SDoc
forall a. Outputable a => a -> SDoc
ppr XRec (GhcPass p) Safety
GenLocated EpaLocation Safety
safety
      SDoc -> SDoc -> SDoc
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 -> SDoc
forall doc. IsOutput doc => doc
empty
               Just (Header SourceText
_ FastString
header) -> FastString -> SDoc
forall doc. IsLine doc => FastString -> doc
ftext FastString
header

      pprCEntity :: CImportSpec -> String -> SDoc
pprCEntity (CLabel FastString
lbl) String
_ =
        SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
doubleQuotes (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"static" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_hdr SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'&' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
lbl
      pprCEntity (CFunction (StaticTarget SourceText
st FastString
_lbl Maybe Unit
_ Bool
isFun)) String
src =
        if Bool
dqNeeded then SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
doubleQuotes SDoc
ce else SDoc
forall doc. IsOutput doc => doc
empty
          where
            dqNeeded :: Bool
dqNeeded = (Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
6 String
src String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"static")
                    Bool -> Bool -> Bool
|| Maybe Header -> Bool
forall a. Maybe a -> Bool
isJust Maybe Header
mHeader
                    Bool -> Bool -> Bool
|| Bool -> Bool
not Bool
isFun
                    Bool -> Bool -> Bool
|| SourceText
st SourceText -> SourceText -> Bool
forall a. Eq a => a -> a -> Bool
/= SourceText
NoSourceText
            ce :: SDoc
ce =
                  -- We may need to drop leading spaces first
                  (if Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
6 String
src String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"static" then String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"static" else SDoc
forall doc. IsOutput doc => doc
empty)
              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_hdr
              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (if Bool
isFun then SDoc
forall doc. IsOutput doc => doc
empty else String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"value")
              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st SDoc
forall doc. IsOutput doc => doc
empty)
      pprCEntity (CFunction CCallTarget
DynamicTarget) String
_ =
        SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
doubleQuotes (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"dynamic"
      pprCEntity CImportSpec
CWrapper String
_ = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
doubleQuotes (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
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 EpaLocation
_ (CExportStatic SourceText
_ FastString
lbl CCallConv
cconv))) =
    CCallConv -> SDoc
forall a. Outputable a => a -> SDoc
ppr CCallConv
cconv SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'"' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
lbl SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'"'

{-
************************************************************************
*                                                                      *
\subsection{Rewrite rules}
*                                                                      *
************************************************************************
-}

type instance XCRuleDecls    GhcPs = ((EpaLocation, EpToken "#-}"), SourceText)
type instance XCRuleDecls    GhcRn = SourceText
type instance XCRuleDecls    GhcTc = SourceText

type instance XXRuleDecls    (GhcPass _) = DataConCantHappen

type instance XHsRule       GhcPs = (HsRuleAnn, SourceText)
type instance XHsRule       GhcRn = (HsRuleRn, SourceText)
type instance XHsRule       GhcTc = (HsRuleRn, SourceText)

data HsRuleRn = HsRuleRn NameSet NameSet -- Free-vars from the LHS and RHS
  deriving Typeable HsRuleRn
Typeable HsRuleRn =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> HsRuleRn -> c HsRuleRn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsRuleRn)
-> (HsRuleRn -> Constr)
-> (HsRuleRn -> DataType)
-> (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))
-> ((forall b. Data b => b -> b) -> HsRuleRn -> HsRuleRn)
-> (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 u. (forall d. Data d => d -> u) -> HsRuleRn -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> HsRuleRn -> u)
-> (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 (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn)
-> Data HsRuleRn
HsRuleRn -> Constr
HsRuleRn -> DataType
(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)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleRn -> c HsRuleRn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleRn -> c HsRuleRn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleRn
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleRn
$ctoConstr :: HsRuleRn -> Constr
toConstr :: HsRuleRn -> Constr
$cdataTypeOf :: HsRuleRn -> DataType
dataTypeOf :: HsRuleRn -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleRn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleRn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleRn)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleRn)
$cgmapT :: (forall b. Data b => b -> b) -> HsRuleRn -> HsRuleRn
gmapT :: (forall b. Data b => b -> b) -> HsRuleRn -> HsRuleRn
$cgmapQl :: 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
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleRn -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleRn -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleRn -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleRn -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleRn -> u
$cgmapM :: forall (m :: * -> *).
Monad 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
$cgmapMp :: 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
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleRn -> m HsRuleRn
Data

type instance XXRuleDecl    (GhcPass _) = DataConCantHappen

data HsRuleAnn
  = HsRuleAnn
       { HsRuleAnn -> Maybe (TokForall, EpToken ".")
ra_tyanns :: Maybe (TokForall, EpToken ".")
       , HsRuleAnn -> Maybe (TokForall, EpToken ".")
ra_tmanns :: Maybe (TokForall, EpToken ".")
       , HsRuleAnn -> EpToken "="
ra_equal  :: EpToken "="
       , HsRuleAnn -> ActivationAnn
ra_rest :: ActivationAnn
       } deriving (Typeable HsRuleAnn
Typeable HsRuleAnn =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> HsRuleAnn -> c HsRuleAnn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsRuleAnn)
-> (HsRuleAnn -> Constr)
-> (HsRuleAnn -> DataType)
-> (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))
-> ((forall b. Data b => b -> b) -> HsRuleAnn -> HsRuleAnn)
-> (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 u. (forall d. Data d => d -> u) -> HsRuleAnn -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> HsRuleAnn -> u)
-> (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 (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn)
-> Data HsRuleAnn
HsRuleAnn -> Constr
HsRuleAnn -> DataType
(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)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleAnn -> c HsRuleAnn
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsRuleAnn -> c HsRuleAnn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleAnn
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsRuleAnn
$ctoConstr :: HsRuleAnn -> Constr
toConstr :: HsRuleAnn -> Constr
$cdataTypeOf :: HsRuleAnn -> DataType
dataTypeOf :: HsRuleAnn -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleAnn)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsRuleAnn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleAnn)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsRuleAnn)
$cgmapT :: (forall b. Data b => b -> b) -> HsRuleAnn -> HsRuleAnn
gmapT :: (forall b. Data b => b -> b) -> HsRuleAnn -> HsRuleAnn
$cgmapQl :: 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
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsRuleAnn -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleAnn -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> HsRuleAnn -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleAnn -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsRuleAnn -> u
$cgmapM :: forall (m :: * -> *).
Monad 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
$cgmapMp :: 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
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsRuleAnn -> m HsRuleAnn
Data, HsRuleAnn -> HsRuleAnn -> Bool
(HsRuleAnn -> HsRuleAnn -> Bool)
-> (HsRuleAnn -> HsRuleAnn -> Bool) -> Eq HsRuleAnn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HsRuleAnn -> HsRuleAnn -> Bool
== :: HsRuleAnn -> HsRuleAnn -> Bool
$c/= :: HsRuleAnn -> HsRuleAnn -> Bool
/= :: HsRuleAnn -> HsRuleAnn -> Bool
Eq)

instance NoAnn HsRuleAnn where
  noAnn :: HsRuleAnn
noAnn = Maybe (TokForall, EpToken ".")
-> Maybe (TokForall, EpToken ".")
-> EpToken "="
-> ActivationAnn
-> HsRuleAnn
HsRuleAnn Maybe (TokForall, EpToken ".")
forall a. Maybe a
Nothing Maybe (TokForall, EpToken ".")
forall a. Maybe a
Nothing EpToken "="
forall a. NoAnn a => a
noAnn ActivationAnn
forall a. NoAnn a => a
noAnn

flattenRuleDecls :: [LRuleDecls (GhcPass p)] -> [LRuleDecl (GhcPass p)]
flattenRuleDecls :: forall (p :: Pass).
[LRuleDecls (GhcPass p)] -> [LRuleDecl (GhcPass p)]
flattenRuleDecls [LRuleDecls (GhcPass p)]
decls = (GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))
 -> [GenLocated SrcSpanAnnA (RuleDecl (GhcPass p))])
-> [GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
-> [GenLocated SrcSpanAnnA (RuleDecl (GhcPass p))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (RuleDecls (GhcPass p) -> [XRec (GhcPass p) (RuleDecl (GhcPass p))]
RuleDecls (GhcPass p)
-> [GenLocated SrcSpanAnnA (RuleDecl (GhcPass p))]
forall pass. RuleDecls pass -> [LRuleDecl pass]
rds_rules (RuleDecls (GhcPass p)
 -> [GenLocated SrcSpanAnnA (RuleDecl (GhcPass p))])
-> (GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))
    -> RuleDecls (GhcPass p))
-> GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))
-> [GenLocated SrcSpanAnnA (RuleDecl (GhcPass p))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))
-> RuleDecls (GhcPass p)
forall l e. GenLocated l e -> e
unLoc) [LRuleDecls (GhcPass p)]
[GenLocated SrcSpanAnnA (RuleDecls (GhcPass p))]
decls

type instance XCRuleBndr    (GhcPass _) = AnnTyVarBndr
type instance XRuleBndrSig  (GhcPass _) = AnnTyVarBndr
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 (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"{-# RULES")
          SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
semi ((GenLocated SrcSpanAnnA (RuleDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (RuleDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (RuleDecl (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LRuleDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (RuleDecl (GhcPass p))]
rules)) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
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 | ((EpaLocation, EpToken "#-}")
_, SourceText
st) <- XCRuleDecls (GhcPass p)
ext -> SourceText
st
                           GhcPass p
GhcRn -> XCRuleDecls (GhcPass p)
SourceText
ext
                           GhcPass p
GhcTc -> XCRuleDecls (GhcPass p)
SourceText
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 FastString
rd_name = XRec (GhcPass p) FastString
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 })
        = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SourceText -> GenLocated (Anno FastString) FastString -> SDoc
forall a. SourceText -> GenLocated a FastString -> SDoc
pprFullRuleName SourceText
st XRec (GhcPass p) FastString
GenLocated (Anno FastString) FastString
name SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Activation -> SDoc
forall a. Outputable a => a -> SDoc
ppr Activation
act,
               Int -> SDoc -> SDoc
nest Int
4 (Maybe
  [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
-> SDoc
forall {a}. Outputable a => Maybe [a] -> SDoc
pp_forall_ty Maybe [LHsTyVarBndr () (NoGhcTc (GhcPass p))]
Maybe
  [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
tys SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe
  [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
-> SDoc
pp_forall_tm Maybe [LHsTyVarBndr () (NoGhcTc (GhcPass p))]
Maybe
  [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
tys
                                        SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (GenLocated (Anno (HsExpr (GhcPass p))) (HsExpr (GhcPass p))
-> HsExpr (GhcPass p)
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated (Anno (HsExpr (GhcPass p))) (HsExpr (GhcPass p))
lhs)),
               Int -> SDoc -> SDoc
nest Int
6 (SDoc
forall doc. IsLine doc => doc
equals SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (GenLocated (Anno (HsExpr (GhcPass p))) (HsExpr (GhcPass p))
-> HsExpr (GhcPass p)
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated (Anno (HsExpr (GhcPass p))) (HsExpr (GhcPass p))
rhs)) ]
        where
          pp_forall_ty :: Maybe [a] -> SDoc
pp_forall_ty Maybe [a]
Nothing     = SDoc
forall doc. IsOutput doc => doc
empty
          pp_forall_ty (Just [a]
qtvs) = SDoc
forAllLit SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
fsep ((a -> SDoc) -> [a] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map a -> SDoc
forall a. Outputable a => a -> SDoc
ppr [a]
qtvs) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
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 | [GenLocated EpAnnCO (RuleBndr (GhcPass p))] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LRuleBndr (GhcPass p)]
[GenLocated EpAnnCO (RuleBndr (GhcPass p))]
tms = SDoc
forall doc. IsOutput doc => doc
empty
          pp_forall_tm Maybe
  [GenLocated SrcSpanAnnA (HsTyVarBndr () (GhcPass (NoGhcTcPass p)))]
_ = SDoc
forAllLit SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
fsep ((GenLocated EpAnnCO (RuleBndr (GhcPass p)) -> SDoc)
-> [GenLocated EpAnnCO (RuleBndr (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated EpAnnCO (RuleBndr (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LRuleBndr (GhcPass p)]
[GenLocated EpAnnCO (RuleBndr (GhcPass p))]
tms) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
dot
          st :: SourceText
st = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
                 GhcPass p
GhcPs | (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) = GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
name
   ppr (RuleBndrSig XRuleBndrSig (GhcPass p)
_ LIdP (GhcPass p)
name HsPatSigType (GhcPass p)
ty) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
name SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> HsPatSigType (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsPatSigType (GhcPass p)
ty)

pprFullRuleName :: SourceText -> GenLocated a (RuleName) -> SDoc
pprFullRuleName :: forall a. SourceText -> GenLocated a FastString -> SDoc
pprFullRuleName SourceText
st (L a
_ FastString
n) = SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
doubleQuotes (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ FastString -> SDoc
forall doc. IsLine doc => FastString -> doc
ftext FastString
n)


{-
************************************************************************
*                                                                      *
\subsection[DeprecDecl]{Deprecations}
*                                                                      *
************************************************************************
-}

type instance XWarnings      GhcPs = ((EpaLocation, EpToken "#-}"), SourceText)
type instance XWarnings      GhcRn = SourceText
type instance XWarnings      GhcTc = SourceText

type instance XXWarnDecls    (GhcPass _) = DataConCantHappen

type instance XWarning      (GhcPass _) = (NamespaceSpecifier, (EpToken "[", EpToken "]"))
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)
      = FastString -> SDoc
forall doc. IsLine doc => FastString -> doc
ftext FastString
src SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
semi ((GenLocated SrcSpanAnnA (WarnDecl (GhcPass p)) -> SDoc)
-> [GenLocated SrcSpanAnnA (WarnDecl (GhcPass p))] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (WarnDecl (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LWarnDecl (GhcPass p)]
[GenLocated SrcSpanAnnA (WarnDecl (GhcPass p))]
decls)) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"#-}"
      where src :: FastString
src = case forall (p :: Pass). IsPass p => GhcPass p
ghcPass @p of
              GhcPass p
GhcPs | ((EpaLocation, EpToken "#-}")
_, SourceText FastString
src) <- XWarnings (GhcPass p)
ext -> FastString
src
              GhcPass p
GhcRn | SourceText FastString
src <- XWarnings (GhcPass p)
ext -> FastString
src
              GhcPass p
GhcTc | SourceText FastString
src <- XWarnings (GhcPass p)
ext -> FastString
src
              GhcPass p
_ -> String -> FastString
forall a. HasCallStack => String -> a
panic String
"WarnDecls"

instance OutputableBndrId p
       => Outputable (WarnDecl (GhcPass p)) where
    ppr :: WarnDecl (GhcPass p) -> SDoc
ppr (Warning (NamespaceSpecifier
ns_spec, (EpToken "[", EpToken "]")
_) [LIdP (GhcPass p)]
thing WarningTxt (GhcPass p)
txt)
      = SDoc
ppr_category
              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> NamespaceSpecifier -> SDoc
forall a. Outputable a => a -> SDoc
ppr NamespaceSpecifier
ns_spec
              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep (SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
comma ((GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc)
-> [GenLocated (Anno (IdGhcP p)) (IdGhcP p)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr [LIdP (GhcPass p)]
[GenLocated (Anno (IdGhcP p)) (IdGhcP p)]
thing))
              SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> WarningTxt (GhcPass p) -> SDoc
forall a. Outputable a => a -> SDoc
ppr WarningTxt (GhcPass p)
txt
      where
        ppr_category :: SDoc
ppr_category = case WarningTxt (GhcPass p)
txt of
                         WarningTxt (Just LocatedE InWarningCategory
cat) SourceText
_ [LocatedE (WithHsDocIdentifiers StringLiteral (GhcPass p))]
_ -> LocatedE InWarningCategory -> SDoc
forall a. Outputable a => a -> SDoc
ppr LocatedE InWarningCategory
cat
                         WarningTxt (GhcPass p)
_ -> SDoc
forall doc. IsOutput doc => doc
empty

{-
************************************************************************
*                                                                      *
\subsection[AnnDecl]{Annotations}
*                                                                      *
************************************************************************
-}

type instance XHsAnnotation (GhcPass _) = (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)
      = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"{-#", AnnProvenance (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
AnnProvenance (GhcPass p) -> SDoc
pprAnnProvenance AnnProvenance (GhcPass p)
provenance, HsExpr (GhcPass p) -> SDoc
forall (p :: Pass).
OutputableBndrId p =>
HsExpr (GhcPass p) -> SDoc
pprExpr (GenLocated (Anno (HsExpr (GhcPass p))) (HsExpr (GhcPass p))
-> HsExpr (GhcPass p)
forall l e. GenLocated l e -> e
unLoc XRec (GhcPass p) (HsExpr (GhcPass p))
GenLocated (Anno (HsExpr (GhcPass p))) (HsExpr (GhcPass p))
expr), String -> SDoc
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       = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ANN module"
pprAnnProvenance (ValueAnnProvenance (L Anno (IdGhcP p)
_ IdGhcP p
name))
  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ANN" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IdGhcP p -> SDoc
forall a. Outputable a => a -> SDoc
ppr IdGhcP p
name
pprAnnProvenance (TypeAnnProvenance (L Anno (IdGhcP p)
_ IdGhcP p
name))
  = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ANN type" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IdGhcP p -> SDoc
forall a. Outputable a => a -> SDoc
ppr IdGhcP p
name

{-
************************************************************************
*                                                                      *
\subsection[RoleAnnot]{Role annotations}
*                                                                      *
************************************************************************
-}

type instance XCRoleAnnotDecl GhcPs = (EpToken "type", EpToken "role")
type instance XCRoleAnnotDecl GhcRn = NoExtField
type instance XCRoleAnnotDecl GhcTc = NoExtField

type instance XXRoleAnnotDecl (GhcPass _) = DataConCantHappen

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)
    = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type role" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IdGhcP p -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc (GenLocated (Anno (IdGhcP p)) (IdGhcP p) -> IdGhcP p
forall l e. GenLocated l e -> e
unLoc LIdP (GhcPass p)
GenLocated (Anno (IdGhcP p)) (IdGhcP p)
ltycon) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
      [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep ((GenLocated EpAnnCO (Maybe Role) -> SDoc)
-> [GenLocated EpAnnCO (Maybe Role)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (Maybe Role -> SDoc
forall {a}. Outputable a => Maybe a -> SDoc
pp_role (Maybe Role -> SDoc)
-> (GenLocated EpAnnCO (Maybe Role) -> Maybe Role)
-> GenLocated EpAnnCO (Maybe Role)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated EpAnnCO (Maybe Role) -> Maybe Role
forall l e. GenLocated l e -> e
unLoc) [XRec (GhcPass p) (Maybe Role)]
[GenLocated EpAnnCO (Maybe Role)]
roles)
    where
      pp_role :: Maybe a -> SDoc
pp_role Maybe a
Nothing  = SDoc
forall doc. IsLine doc => doc
underscore
      pp_role (Just a
r) = a -> SDoc
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)]
_) = IdP (GhcPass p)
IdGhcP p
name

{-
************************************************************************
*                                                                      *
\subsection{Anno instances}
*                                                                      *
************************************************************************
-}

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)) = EpAnnCO
type instance Anno (FamilyDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (InjectivityAnn (GhcPass p)) = EpAnnCO
type instance Anno CType = SrcSpanAnnP
type instance Anno (HsDerivingClause (GhcPass p)) = EpAnnCO
type instance Anno (DerivClauseTys (GhcPass _)) = SrcSpanAnnC
type instance Anno (StandaloneKindSig (GhcPass p)) = SrcSpanAnnA
type instance Anno (ConDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno Bool = EpAnnCO
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)) = EpAnnCO
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) = EpAnnCO
type instance Anno (RuleBndr (GhcPass p)) = EpAnnCO
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) = EpAnnCO
type instance Anno CCallConv   = EpaLocation
type instance Anno Safety      = EpaLocation
type instance Anno CExportSpec = EpaLocation