{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DeriveTraversable #-}
module GHC.Iface.Syntax (
module GHC.Iface.Type,
IfaceDecl(..), IfaceFamTyConFlav(..), IfaceClassOp(..), IfaceAT(..),
IfaceConDecl(..), IfaceConDecls(..), IfaceEqSpec,
IfaceExpr(..), IfaceAlt(..), IfaceLetBndr(..), IfaceBinding,
IfaceBindingX(..), IfaceMaybeRhs(..), IfaceConAlt(..),
IfaceIdInfo, IfaceIdDetails(..), IfaceUnfolding(..), IfGuidance(..),
IfaceInfoItem(..), IfaceRule(..), IfaceAnnotation(..), IfaceAnnTarget,
IfaceWarnings(..), IfaceWarningTxt(..), IfaceStringLiteral(..),
IfaceDefault(..), IfaceClsInst(..), IfaceFamInst(..), IfaceTickish(..),
IfaceClassBody(..), IfaceBooleanFormula(..),
IfaceBang(..),
IfaceSrcBang(..), SrcUnpackedness(..), SrcStrictness(..),
IfaceAxBranch(..),
IfaceTyConParent(..),
IfaceCompleteMatch(..),
IfaceLFInfo(..), IfaceTopBndrInfo(..),
IfaceImport(..),
ImpIfaceList(..),
IfaceTopBndr,
putIfaceTopBndr, getIfaceTopBndr,
ifaceDeclImplicitBndrs, visibleIfConDecls,
ifaceDeclFingerprints,
fromIfaceBooleanFormula,
fromIfaceWarnings,
fromIfaceWarningTxt,
freeNamesIfDecl, freeNamesIfRule, freeNamesIfFamInst,
freeNamesIfConDecls,
pprIfaceExpr,
pprIfaceDecl,
AltPpr(..), ShowSub(..), ShowHowMuch(..), showToIface, showToHeader
) where
import GHC.Prelude
import GHC.Data.FastString
import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey,
constraintKindTyConKey )
import GHC.Types.Unique ( hasKey )
import GHC.Iface.Type
import GHC.Iface.Recomp.Binary
import GHC.Core( IsOrphan, isOrphan, UnfoldingCache(..) )
import GHC.Types.Demand
import GHC.Types.Cpr
import GHC.Core.Class
import GHC.Types.FieldLabel
import GHC.Types.Name.Set
import GHC.Core.Coercion.Axiom ( BranchIndex )
import GHC.Types.Name
import GHC.Types.Name.Reader
import GHC.Types.CostCentre
import GHC.Types.Literal
import GHC.Types.ForeignCall
import GHC.Types.Annotations( AnnPayload, AnnTarget )
import GHC.Types.Basic
import GHC.Unit.Module
import GHC.Unit.Module.Warnings
import GHC.Types.SrcLoc
import GHC.Types.SourceText
import GHC.Data.BooleanFormula ( BooleanFormula(..), pprBooleanFormula, isTrue )
import GHC.Types.Var( VarBndr(..), binderVar, tyVarSpecToBinders, visArgTypeLike )
import GHC.Core.TyCon ( Role (..), Injectivity(..), tyConBndrVisForAllTyFlag )
import GHC.Core.DataCon (SrcStrictness(..), SrcUnpackedness(..))
import GHC.Builtin.Types ( constraintKindTyConName )
import GHC.Stg.InferTags.TagSig
import GHC.Parser.Annotation (noLocA)
import GHC.Hs.Extension ( GhcRn )
import GHC.Hs.Doc ( WithHsDocIdentifiers(..) )
import GHC.Utils.Lexeme (isLexSym)
import GHC.Utils.Fingerprint
import GHC.Utils.Binary
import GHC.Utils.Binary.Typeable ()
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
import GHC.Utils.Misc( dropList, filterByList, notNull, unzipWith,
seqList, zipWithEqual )
import Control.Monad
import System.IO.Unsafe
import Control.DeepSeq
import Data.Proxy
infixl 3 &&&
data IfaceImport = IfaceImport ImpDeclSpec ImpIfaceList
data ImpIfaceList
= ImpIfaceAll
| ImpIfaceExplicit !IfGlobalRdrEnv
| ImpIfaceEverythingBut !NameSet
type IfaceTopBndr = Name
getIfaceTopBndr :: ReadBinHandle -> IO IfaceTopBndr
getIfaceTopBndr :: ReadBinHandle -> IO IfExtName
getIfaceTopBndr ReadBinHandle
bh = ReadBinHandle -> IO IfExtName
forall a. Binary a => ReadBinHandle -> IO a
get ReadBinHandle
bh
putIfaceTopBndr :: WriteBinHandle -> IfaceTopBndr -> IO ()
putIfaceTopBndr :: WriteBinHandle -> IfExtName -> IO ()
putIfaceTopBndr WriteBinHandle
bh IfExtName
name =
case Proxy BindingName -> WriteBinHandle -> BinaryWriter BindingName
forall a. Typeable a => Proxy a -> WriteBinHandle -> BinaryWriter a
findUserDataWriter (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @BindingName) WriteBinHandle
bh of
BinaryWriter BindingName
tbl ->
BinaryWriter BindingName -> WriteBinHandle -> BindingName -> IO ()
forall s. BinaryWriter s -> WriteBinHandle -> s -> IO ()
putEntry BinaryWriter BindingName
tbl WriteBinHandle
bh (IfExtName -> BindingName
BindingName IfExtName
name)
data IfaceDecl
= IfaceId { IfaceDecl -> IfExtName
ifName :: IfaceTopBndr,
IfaceDecl -> IfaceType
ifType :: IfaceType,
IfaceDecl -> IfaceIdDetails
ifIdDetails :: IfaceIdDetails,
IfaceDecl -> IfaceIdInfo
ifIdInfo :: IfaceIdInfo
}
| IfaceData { ifName :: IfaceTopBndr,
IfaceDecl -> [IfaceTyConBinder]
ifBinders :: [IfaceTyConBinder],
IfaceDecl -> IfaceType
ifResKind :: IfaceType,
IfaceDecl -> Maybe CType
ifCType :: Maybe CType,
IfaceDecl -> [Role]
ifRoles :: [Role],
IfaceDecl -> IfaceContext
ifCtxt :: IfaceContext,
IfaceDecl -> IfaceConDecls
ifCons :: IfaceConDecls,
IfaceDecl -> Bool
ifGadtSyntax :: Bool,
IfaceDecl -> IfaceTyConParent
ifParent :: IfaceTyConParent
}
| IfaceSynonym { ifName :: IfaceTopBndr,
ifRoles :: [Role],
ifBinders :: [IfaceTyConBinder],
ifResKind :: IfaceKind,
IfaceDecl -> IfaceType
ifSynRhs :: IfaceType }
| IfaceFamily { ifName :: IfaceTopBndr,
IfaceDecl -> Maybe IfLclName
ifResVar :: Maybe IfLclName,
ifBinders :: [IfaceTyConBinder],
ifResKind :: IfaceKind,
IfaceDecl -> IfaceFamTyConFlav
ifFamFlav :: IfaceFamTyConFlav,
IfaceDecl -> Injectivity
ifFamInj :: Injectivity }
| IfaceClass { ifName :: IfaceTopBndr,
ifRoles :: [Role],
ifBinders :: [IfaceTyConBinder],
IfaceDecl -> [FunDep IfLclName]
ifFDs :: [FunDep IfLclName],
IfaceDecl -> IfaceClassBody
ifBody :: IfaceClassBody
}
| IfaceAxiom { ifName :: IfaceTopBndr,
IfaceDecl -> IfaceTyCon
ifTyCon :: IfaceTyCon,
IfaceDecl -> Role
ifRole :: Role,
IfaceDecl -> [IfaceAxBranch]
ifAxBranches :: [IfaceAxBranch]
}
| IfacePatSyn { ifName :: IfaceTopBndr,
IfaceDecl -> Bool
ifPatIsInfix :: Bool,
IfaceDecl -> (IfExtName, Bool)
ifPatMatcher :: (IfExtName, Bool),
IfaceDecl -> Maybe (IfExtName, Bool)
ifPatBuilder :: Maybe (IfExtName, Bool),
IfaceDecl -> [IfaceForAllSpecBndr]
ifPatUnivBndrs :: [IfaceForAllSpecBndr],
IfaceDecl -> [IfaceForAllSpecBndr]
ifPatExBndrs :: [IfaceForAllSpecBndr],
IfaceDecl -> IfaceContext
ifPatProvCtxt :: IfaceContext,
IfaceDecl -> IfaceContext
ifPatReqCtxt :: IfaceContext,
IfaceDecl -> IfaceContext
ifPatArgs :: [IfaceType],
IfaceDecl -> IfaceType
ifPatTy :: IfaceType,
IfaceDecl -> [FieldLabel]
ifFieldLabels :: [FieldLabel] }
data IfaceClassBody
= IfAbstractClass
| IfConcreteClass {
IfaceClassBody -> IfaceContext
ifClassCtxt :: IfaceContext,
IfaceClassBody -> [IfaceAT]
ifATs :: [IfaceAT],
IfaceClassBody -> [IfaceClassOp]
ifSigs :: [IfaceClassOp],
IfaceClassBody -> IfaceBooleanFormula
ifMinDef :: IfaceBooleanFormula
}
data IfaceBooleanFormula
= IfVar IfLclName
| IfAnd [IfaceBooleanFormula]
| IfOr [IfaceBooleanFormula]
| IfParens IfaceBooleanFormula
fromIfaceBooleanFormula :: IfaceBooleanFormula -> BooleanFormula IfLclName
fromIfaceBooleanFormula :: IfaceBooleanFormula -> BooleanFormula IfLclName
fromIfaceBooleanFormula = \case
IfVar IfLclName
nm -> IfLclName -> BooleanFormula IfLclName
forall a. a -> BooleanFormula a
Var IfLclName
nm
IfAnd [IfaceBooleanFormula]
ibfs -> [LBooleanFormula IfLclName] -> BooleanFormula IfLclName
forall a. [LBooleanFormula a] -> BooleanFormula a
And ((IfaceBooleanFormula -> LBooleanFormula IfLclName)
-> [IfaceBooleanFormula] -> [LBooleanFormula IfLclName]
forall a b. (a -> b) -> [a] -> [b]
map (BooleanFormula IfLclName -> LBooleanFormula IfLclName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (BooleanFormula IfLclName -> LBooleanFormula IfLclName)
-> (IfaceBooleanFormula -> BooleanFormula IfLclName)
-> IfaceBooleanFormula
-> LBooleanFormula IfLclName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IfaceBooleanFormula -> BooleanFormula IfLclName
fromIfaceBooleanFormula) [IfaceBooleanFormula]
ibfs)
IfOr [IfaceBooleanFormula]
ibfs -> [LBooleanFormula IfLclName] -> BooleanFormula IfLclName
forall a. [LBooleanFormula a] -> BooleanFormula a
Or ((IfaceBooleanFormula -> LBooleanFormula IfLclName)
-> [IfaceBooleanFormula] -> [LBooleanFormula IfLclName]
forall a b. (a -> b) -> [a] -> [b]
map (BooleanFormula IfLclName -> LBooleanFormula IfLclName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (BooleanFormula IfLclName -> LBooleanFormula IfLclName)
-> (IfaceBooleanFormula -> BooleanFormula IfLclName)
-> IfaceBooleanFormula
-> LBooleanFormula IfLclName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IfaceBooleanFormula -> BooleanFormula IfLclName
fromIfaceBooleanFormula) [IfaceBooleanFormula]
ibfs)
IfParens IfaceBooleanFormula
ibf -> LBooleanFormula IfLclName -> BooleanFormula IfLclName
forall a. LBooleanFormula a -> BooleanFormula a
Parens (BooleanFormula IfLclName -> LBooleanFormula IfLclName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (BooleanFormula IfLclName -> LBooleanFormula IfLclName)
-> (IfaceBooleanFormula -> BooleanFormula IfLclName)
-> IfaceBooleanFormula
-> LBooleanFormula IfLclName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IfaceBooleanFormula -> BooleanFormula IfLclName
fromIfaceBooleanFormula (IfaceBooleanFormula -> LBooleanFormula IfLclName)
-> IfaceBooleanFormula -> LBooleanFormula IfLclName
forall a b. (a -> b) -> a -> b
$ IfaceBooleanFormula
ibf)
data IfaceTyConParent
= IfNoParent
| IfDataInstance
IfExtName
IfaceTyCon
IfaceAppArgs
data IfaceFamTyConFlav
= IfaceDataFamilyTyCon
| IfaceOpenSynFamilyTyCon
| IfaceClosedSynFamilyTyCon (Maybe (IfExtName, [IfaceAxBranch]))
| IfaceAbstractClosedSynFamilyTyCon
| IfaceBuiltInSynFamTyCon
data IfaceClassOp
= IfaceClassOp IfaceTopBndr
IfaceType
(Maybe (DefMethSpec IfaceType))
data IfaceAT = IfaceAT
IfaceDecl
(Maybe IfaceType)
data IfaceAxBranch = IfaceAxBranch { IfaceAxBranch -> [IfaceTvBndr]
ifaxbTyVars :: [IfaceTvBndr]
, IfaceAxBranch -> [IfaceTvBndr]
ifaxbEtaTyVars :: [IfaceTvBndr]
, IfaceAxBranch -> [IfaceIdBndr]
ifaxbCoVars :: [IfaceIdBndr]
, IfaceAxBranch -> IfaceAppArgs
ifaxbLHS :: IfaceAppArgs
, IfaceAxBranch -> [Role]
ifaxbRoles :: [Role]
, IfaceAxBranch -> IfaceType
ifaxbRHS :: IfaceType
, IfaceAxBranch -> [Int]
ifaxbIncomps :: [BranchIndex] }
data IfaceConDecls
= IfAbstractTyCon
| IfDataTyCon !Bool [IfaceConDecl]
| IfNewTyCon IfaceConDecl
data IfaceConDecl
= IfCon {
IfaceConDecl -> IfExtName
ifConName :: IfaceTopBndr,
IfaceConDecl -> Bool
ifConWrapper :: Bool,
IfaceConDecl -> Bool
ifConInfix :: Bool,
IfaceConDecl -> [IfaceBndr]
ifConExTCvs :: [IfaceBndr],
IfaceConDecl -> [IfaceForAllSpecBndr]
ifConUserTvBinders :: [IfaceForAllSpecBndr],
IfaceConDecl -> [IfaceTvBndr]
ifConEqSpec :: IfaceEqSpec,
IfaceConDecl -> IfaceContext
ifConCtxt :: IfaceContext,
IfaceConDecl -> [(IfaceType, IfaceType)]
ifConArgTys :: [(IfaceMult, IfaceType)],
IfaceConDecl -> [FieldLabel]
ifConFields :: [FieldLabel],
IfaceConDecl -> [IfaceBang]
ifConStricts :: [IfaceBang],
IfaceConDecl -> [IfaceSrcBang]
ifConSrcStricts :: [IfaceSrcBang] }
type IfaceEqSpec = [(IfLclName,IfaceType)]
data IfaceBang
= IfNoBang | IfStrict | IfUnpack | IfUnpackCo IfaceCoercion
data IfaceSrcBang
= IfSrcBang SrcUnpackedness SrcStrictness
data IfaceDefault
= IfaceDefault { IfaceDefault -> IfaceTyCon
ifDefaultCls :: IfaceTyCon,
IfaceDefault -> IfaceContext
ifDefaultTys :: [IfaceType],
IfaceDefault -> Maybe IfaceWarningTxt
ifDefaultWarn :: Maybe IfaceWarningTxt }
data IfaceClsInst
= IfaceClsInst { IfaceClsInst -> IfExtName
ifInstCls :: IfExtName,
IfaceClsInst -> [Maybe IfaceTyCon]
ifInstTys :: [Maybe IfaceTyCon],
IfaceClsInst -> IfExtName
ifDFun :: IfExtName,
IfaceClsInst -> OverlapFlag
ifOFlag :: OverlapFlag,
IfaceClsInst -> IsOrphan
ifInstOrph :: IsOrphan,
IfaceClsInst -> Maybe IfaceWarningTxt
ifInstWarn :: Maybe IfaceWarningTxt }
data IfaceFamInst
= IfaceFamInst { IfaceFamInst -> IfExtName
ifFamInstFam :: IfExtName
, IfaceFamInst -> [Maybe IfaceTyCon]
ifFamInstTys :: [Maybe IfaceTyCon]
, IfaceFamInst -> IfExtName
ifFamInstAxiom :: IfExtName
, IfaceFamInst -> IsOrphan
ifFamInstOrph :: IsOrphan
}
data IfaceRule
= IfaceRule {
IfaceRule -> FastString
ifRuleName :: RuleName,
IfaceRule -> Activation
ifActivation :: Activation,
IfaceRule -> [IfaceBndr]
ifRuleBndrs :: [IfaceBndr],
IfaceRule -> IfExtName
ifRuleHead :: IfExtName,
IfaceRule -> [IfaceExpr]
ifRuleArgs :: [IfaceExpr],
IfaceRule -> IfaceExpr
ifRuleRhs :: IfaceExpr,
IfaceRule -> Bool
ifRuleAuto :: Bool,
IfaceRule -> IsOrphan
ifRuleOrph :: IsOrphan
}
data IfaceWarnings
= IfWarnAll IfaceWarningTxt
| IfWarnSome [(OccName, IfaceWarningTxt)]
[(IfExtName, IfaceWarningTxt)]
data IfaceWarningTxt
= IfWarningTxt (Maybe WarningCategory) SourceText [(IfaceStringLiteral, [IfExtName])]
| IfDeprecatedTxt SourceText [(IfaceStringLiteral, [IfExtName])]
data IfaceStringLiteral
= IfStringLiteral SourceText FastString
data IfaceAnnotation
= IfaceAnnotation {
IfaceAnnotation -> IfaceAnnTarget
ifAnnotatedTarget :: IfaceAnnTarget,
IfaceAnnotation -> AnnPayload
ifAnnotatedValue :: AnnPayload
}
type IfaceAnnTarget = AnnTarget OccName
data IfaceCompleteMatch = IfaceCompleteMatch [IfExtName] (Maybe IfExtName)
instance Outputable IfaceCompleteMatch where
ppr :: IfaceCompleteMatch -> SDoc
ppr (IfaceCompleteMatch [IfExtName]
cls Maybe IfExtName
mtc) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"COMPLETE" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [IfExtName] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IfExtName]
cls SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> case Maybe IfExtName
mtc of
Maybe IfExtName
Nothing -> SDoc
forall doc. IsOutput doc => doc
empty
Just IfExtName
tc -> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
tc
type IfaceIdInfo = [IfaceInfoItem]
data IfaceInfoItem
= HsArity Arity
| HsDmdSig DmdSig
| HsCprSig CprSig
| HsInline InlinePragma
| HsUnfold Bool
IfaceUnfolding
| HsNoCafRefs
| HsLFInfo IfaceLFInfo
| HsTagSig TagSig
data IfaceUnfolding
= IfCoreUnfold UnfoldingSource
IfUnfoldingCache
IfGuidance
IfaceExpr
| IfDFunUnfold [IfaceBndr] [IfaceExpr]
type IfUnfoldingCache = UnfoldingCache
data IfGuidance
= IfNoGuidance
| IfWhen Arity Bool Bool
data IfaceIdDetails
= IfVanillaId
| IfWorkerLikeId [CbvMark]
| IfRecSelId
{ IfaceIdDetails -> Either IfaceTyCon IfaceDecl
ifRecSelIdParent :: Either IfaceTyCon IfaceDecl
, IfaceIdDetails -> IfExtName
ifRecSelFirstCon :: IfaceTopBndr
, IfaceIdDetails -> Bool
ifRecSelIdIsNaughty :: Bool
, IfaceIdDetails -> FieldLabel
ifRecSelIdFieldLabel :: FieldLabel }
| IfDFunId
data IfaceLFInfo
= IfLFReEntrant !RepArity
| IfLFThunk
!Bool
!Bool
| IfLFCon !Name
| IfLFUnknown !Bool
| IfLFUnlifted
instance Outputable IfaceLFInfo where
ppr :: IfaceLFInfo -> SDoc
ppr (IfLFReEntrant Int
arity) =
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LFReEntrant" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
arity
ppr (IfLFThunk Bool
updatable Bool
mb_fun) =
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LFThunk" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens
(String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"updatable=" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
updatable SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"might_be_function=" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
mb_fun)
ppr (IfLFCon IfExtName
con) =
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LFCon" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets (IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
con)
ppr IfaceLFInfo
IfLFUnlifted =
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LFUnlifted"
ppr (IfLFUnknown Bool
fun_flag) =
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LFUnknown" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
fun_flag
instance Binary IfaceLFInfo where
put_ :: WriteBinHandle -> IfaceLFInfo -> IO ()
put_ WriteBinHandle
bh (IfLFReEntrant Int
arity) = do
WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
0
WriteBinHandle -> Int -> IO ()
forall a. Binary a => WriteBinHandle -> a -> IO ()
put_ WriteBinHandle
bh Int
arity
put_ WriteBinHandle
bh (IfLFThunk Bool
updatable Bool
mb_fun) = do
WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
1
WriteBinHandle -> Bool -> IO ()
forall a. Binary a => WriteBinHandle -> a -> IO ()
put_ WriteBinHandle
bh Bool
updatable
WriteBinHandle -> Bool -> IO ()
forall a. Binary a => WriteBinHandle -> a -> IO ()
put_ WriteBinHandle
bh Bool
mb_fun
put_ WriteBinHandle
bh (IfLFCon IfExtName
con_name) = do
WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
2
WriteBinHandle -> IfExtName -> IO ()
forall a. Binary a => WriteBinHandle -> a -> IO ()
put_ WriteBinHandle
bh IfExtName
con_name
put_ WriteBinHandle
bh (IfLFUnknown Bool
fun_flag) = do
WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
3
WriteBinHandle -> Bool -> IO ()
forall a. Binary a => WriteBinHandle -> a -> IO ()
put_ WriteBinHandle
bh Bool
fun_flag
put_ WriteBinHandle
bh IfaceLFInfo
IfLFUnlifted =
WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
4
get :: ReadBinHandle -> IO IfaceLFInfo
get ReadBinHandle
bh = do
tag <- ReadBinHandle -> IO Word8
getByte ReadBinHandle
bh
case tag of
Word8
0 -> Int -> IfaceLFInfo
IfLFReEntrant (Int -> IfaceLFInfo) -> IO Int -> IO IfaceLFInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadBinHandle -> IO Int
forall a. Binary a => ReadBinHandle -> IO a
get ReadBinHandle
bh
Word8
1 -> Bool -> Bool -> IfaceLFInfo
IfLFThunk (Bool -> Bool -> IfaceLFInfo)
-> IO Bool -> IO (Bool -> IfaceLFInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadBinHandle -> IO Bool
forall a. Binary a => ReadBinHandle -> IO a
get ReadBinHandle
bh IO (Bool -> IfaceLFInfo) -> IO Bool -> IO IfaceLFInfo
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReadBinHandle -> IO Bool
forall a. Binary a => ReadBinHandle -> IO a
get ReadBinHandle
bh
Word8
2 -> IfExtName -> IfaceLFInfo
IfLFCon (IfExtName -> IfaceLFInfo) -> IO IfExtName -> IO IfaceLFInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadBinHandle -> IO IfExtName
forall a. Binary a => ReadBinHandle -> IO a
get ReadBinHandle
bh
Word8
3 -> Bool -> IfaceLFInfo
IfLFUnknown (Bool -> IfaceLFInfo) -> IO Bool -> IO IfaceLFInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadBinHandle -> IO Bool
forall a. Binary a => ReadBinHandle -> IO a
get ReadBinHandle
bh
Word8
4 -> IfaceLFInfo -> IO IfaceLFInfo
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure IfaceLFInfo
IfLFUnlifted
Word8
_ -> String -> IO IfaceLFInfo
forall a. HasCallStack => String -> a
panic String
"Invalid byte"
visibleIfConDecls :: IfaceConDecls -> [IfaceConDecl]
visibleIfConDecls :: IfaceConDecls -> [IfaceConDecl]
visibleIfConDecls (IfAbstractTyCon {}) = []
visibleIfConDecls (IfDataTyCon Bool
_ [IfaceConDecl]
cs) = [IfaceConDecl]
cs
visibleIfConDecls (IfNewTyCon IfaceConDecl
c) = [IfaceConDecl
c]
ifaceDeclImplicitBndrs :: IfaceDecl -> [OccName]
ifaceDeclImplicitBndrs :: IfaceDecl -> [OccName]
ifaceDeclImplicitBndrs (IfaceData {ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
tc_name, ifCons :: IfaceDecl -> IfaceConDecls
ifCons = IfaceConDecls
cons })
= case IfaceConDecls
cons of
IfAbstractTyCon {} -> []
IfNewTyCon IfaceConDecl
cd -> OccName -> OccName
mkNewTyCoOcc (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
tc_name) OccName -> [OccName] -> [OccName]
forall a. a -> [a] -> [a]
: IfaceConDecl -> [OccName]
ifaceConDeclImplicitBndrs IfaceConDecl
cd
IfDataTyCon Bool
type_data [IfaceConDecl]
cds
| Bool
type_data ->
[IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
con_name | IfCon { ifConName :: IfaceConDecl -> IfExtName
ifConName = IfExtName
con_name } <- [IfaceConDecl]
cds]
| Bool
otherwise -> (IfaceConDecl -> [OccName]) -> [IfaceConDecl] -> [OccName]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap IfaceConDecl -> [OccName]
ifaceConDeclImplicitBndrs [IfaceConDecl]
cds
ifaceDeclImplicitBndrs (IfaceClass { ifBody :: IfaceDecl -> IfaceClassBody
ifBody = IfaceClassBody
IfAbstractClass })
= []
ifaceDeclImplicitBndrs (IfaceClass { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
cls_tc_name
, ifBody :: IfaceDecl -> IfaceClassBody
ifBody = IfConcreteClass {
ifClassCtxt :: IfaceClassBody -> IfaceContext
ifClassCtxt = IfaceContext
sc_ctxt,
ifSigs :: IfaceClassBody -> [IfaceClassOp]
ifSigs = [IfaceClassOp]
sigs,
ifATs :: IfaceClassBody -> [IfaceAT]
ifATs = [IfaceAT]
ats
}})
=
[OccName]
co_occs [OccName] -> [OccName] -> [OccName]
forall a. [a] -> [a] -> [a]
++
[OccName
dc_occ, OccName
dcww_occ] [OccName] -> [OccName] -> [OccName]
forall a. [a] -> [a] -> [a]
++
[IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName (IfaceDecl -> IfExtName
ifName IfaceDecl
at) | IfaceAT IfaceDecl
at Maybe IfaceType
_ <- [IfaceAT]
ats ] [OccName] -> [OccName] -> [OccName]
forall a. [a] -> [a] -> [a]
++
[Int -> OccName -> OccName
mkSuperDictSelOcc Int
n OccName
cls_tc_occ | Int
n <- [Int
1..Int
n_ctxt]] [OccName] -> [OccName] -> [OccName]
forall a. [a] -> [a] -> [a]
++
[IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
op | IfaceClassOp IfExtName
op IfaceType
_ Maybe (DefMethSpec IfaceType)
_ <- [IfaceClassOp]
sigs]
where
cls_tc_occ :: OccName
cls_tc_occ = IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
cls_tc_name
n_ctxt :: Int
n_ctxt = IfaceContext -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length IfaceContext
sc_ctxt
n_sigs :: Int
n_sigs = [IfaceClassOp] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [IfaceClassOp]
sigs
co_occs :: [OccName]
co_occs | Bool
is_newtype = [OccName -> OccName
mkNewTyCoOcc OccName
cls_tc_occ]
| Bool
otherwise = []
dcww_occ :: OccName
dcww_occ = OccName -> OccName
mkDataConWorkerOcc OccName
dc_occ
dc_occ :: OccName
dc_occ = OccName -> OccName
mkClassDataConOcc OccName
cls_tc_occ
is_newtype :: Bool
is_newtype = Int
n_sigs Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n_ctxt Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1
ifaceDeclImplicitBndrs IfaceDecl
_ = []
ifaceConDeclImplicitBndrs :: IfaceConDecl -> [OccName]
ifaceConDeclImplicitBndrs :: IfaceConDecl -> [OccName]
ifaceConDeclImplicitBndrs (IfCon {
ifConWrapper :: IfaceConDecl -> Bool
ifConWrapper = Bool
has_wrapper, ifConName :: IfaceConDecl -> IfExtName
ifConName = IfExtName
con_name })
= [IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
con_name, OccName
work_occ] [OccName] -> [OccName] -> [OccName]
forall a. [a] -> [a] -> [a]
++ [OccName]
wrap_occs
where
con_occ :: OccName
con_occ = IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
con_name
work_occ :: OccName
work_occ = OccName -> OccName
mkDataConWorkerOcc OccName
con_occ
wrap_occs :: [OccName]
wrap_occs | Bool
has_wrapper = [OccName -> OccName
mkDataConWrapperOcc OccName
con_occ]
| Bool
otherwise = []
ifaceDeclFingerprints :: Fingerprint -> IfaceDecl -> [(OccName,Fingerprint)]
ifaceDeclFingerprints :: Fingerprint -> IfaceDecl -> [(OccName, Fingerprint)]
ifaceDeclFingerprints Fingerprint
hash IfaceDecl
decl
= (IfaceDecl -> OccName
forall a. NamedThing a => a -> OccName
getOccName IfaceDecl
decl, Fingerprint
hash) (OccName, Fingerprint)
-> [(OccName, Fingerprint)] -> [(OccName, Fingerprint)]
forall a. a -> [a] -> [a]
:
[ (OccName
occ, (Fingerprint, OccName) -> Fingerprint
computeFingerprint' (Fingerprint
hash,OccName
occ))
| OccName
occ <- IfaceDecl -> [OccName]
ifaceDeclImplicitBndrs IfaceDecl
decl ]
where
computeFingerprint' :: (Fingerprint, OccName) -> Fingerprint
computeFingerprint' =
IO Fingerprint -> Fingerprint
forall a. IO a -> a
unsafeDupablePerformIO
(IO Fingerprint -> Fingerprint)
-> ((Fingerprint, OccName) -> IO Fingerprint)
-> (Fingerprint, OccName)
-> Fingerprint
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WriteBinHandle -> IfExtName -> IO ())
-> (Fingerprint, OccName) -> IO Fingerprint
forall a.
Binary a =>
(WriteBinHandle -> IfExtName -> IO ()) -> a -> IO Fingerprint
computeFingerprint (String -> WriteBinHandle -> IfExtName -> IO ()
forall a. HasCallStack => String -> a
panic String
"ifaceDeclFingerprints")
fromIfaceWarnings :: IfaceWarnings -> Warnings GhcRn
fromIfaceWarnings :: IfaceWarnings -> Warnings GhcRn
fromIfaceWarnings = \case
IfWarnAll IfaceWarningTxt
txt -> WarningTxt GhcRn -> Warnings GhcRn
forall pass. WarningTxt pass -> Warnings pass
WarnAll (IfaceWarningTxt -> WarningTxt GhcRn
fromIfaceWarningTxt IfaceWarningTxt
txt)
IfWarnSome [(OccName, IfaceWarningTxt)]
vs [(IfExtName, IfaceWarningTxt)]
ds -> DeclWarnOccNames GhcRn -> ExportWarnNames GhcRn -> Warnings GhcRn
forall pass.
DeclWarnOccNames pass -> ExportWarnNames pass -> Warnings pass
WarnSome [(OccName
occ, IfaceWarningTxt -> WarningTxt GhcRn
fromIfaceWarningTxt IfaceWarningTxt
txt) | (OccName
occ, IfaceWarningTxt
txt) <- [(OccName, IfaceWarningTxt)]
vs]
[(IfExtName
occ, IfaceWarningTxt -> WarningTxt GhcRn
fromIfaceWarningTxt IfaceWarningTxt
txt) | (IfExtName
occ, IfaceWarningTxt
txt) <- [(IfExtName, IfaceWarningTxt)]
ds]
fromIfaceWarningTxt :: IfaceWarningTxt -> WarningTxt GhcRn
fromIfaceWarningTxt :: IfaceWarningTxt -> WarningTxt GhcRn
fromIfaceWarningTxt = \case
IfWarningTxt Maybe WarningCategory
mb_cat SourceText
src [(IfaceStringLiteral, [IfExtName])]
strs -> Maybe (LocatedE InWarningCategory)
-> SourceText
-> [LocatedE (WithHsDocIdentifiers StringLiteral GhcRn)]
-> WarningTxt GhcRn
forall pass.
Maybe (LocatedE InWarningCategory)
-> SourceText
-> [LocatedE (WithHsDocIdentifiers StringLiteral pass)]
-> WarningTxt pass
WarningTxt (InWarningCategory -> LocatedE InWarningCategory
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (InWarningCategory -> LocatedE InWarningCategory)
-> (WarningCategory -> InWarningCategory)
-> WarningCategory
-> LocatedE InWarningCategory
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WarningCategory -> InWarningCategory
fromWarningCategory (WarningCategory -> LocatedE InWarningCategory)
-> Maybe WarningCategory -> Maybe (LocatedE InWarningCategory)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe WarningCategory
mb_cat) SourceText
src (WithHsDocIdentifiers StringLiteral GhcRn
-> LocatedE (WithHsDocIdentifiers StringLiteral GhcRn)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (WithHsDocIdentifiers StringLiteral GhcRn
-> LocatedE (WithHsDocIdentifiers StringLiteral GhcRn))
-> [WithHsDocIdentifiers StringLiteral GhcRn]
-> [LocatedE (WithHsDocIdentifiers StringLiteral GhcRn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((IfaceStringLiteral, [IfExtName])
-> WithHsDocIdentifiers StringLiteral GhcRn)
-> [(IfaceStringLiteral, [IfExtName])]
-> [WithHsDocIdentifiers StringLiteral GhcRn]
forall a b. (a -> b) -> [a] -> [b]
map (IfaceStringLiteral, [IfExtName])
-> WithHsDocIdentifiers StringLiteral GhcRn
fromIfaceStringLiteralWithNames [(IfaceStringLiteral, [IfExtName])]
strs)
IfDeprecatedTxt SourceText
src [(IfaceStringLiteral, [IfExtName])]
strs -> SourceText
-> [LocatedE (WithHsDocIdentifiers StringLiteral GhcRn)]
-> WarningTxt GhcRn
forall pass.
SourceText
-> [LocatedE (WithHsDocIdentifiers StringLiteral pass)]
-> WarningTxt pass
DeprecatedTxt SourceText
src (WithHsDocIdentifiers StringLiteral GhcRn
-> LocatedE (WithHsDocIdentifiers StringLiteral GhcRn)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (WithHsDocIdentifiers StringLiteral GhcRn
-> LocatedE (WithHsDocIdentifiers StringLiteral GhcRn))
-> [WithHsDocIdentifiers StringLiteral GhcRn]
-> [LocatedE (WithHsDocIdentifiers StringLiteral GhcRn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((IfaceStringLiteral, [IfExtName])
-> WithHsDocIdentifiers StringLiteral GhcRn)
-> [(IfaceStringLiteral, [IfExtName])]
-> [WithHsDocIdentifiers StringLiteral GhcRn]
forall a b. (a -> b) -> [a] -> [b]
map (IfaceStringLiteral, [IfExtName])
-> WithHsDocIdentifiers StringLiteral GhcRn
fromIfaceStringLiteralWithNames [(IfaceStringLiteral, [IfExtName])]
strs)
fromIfaceStringLiteralWithNames :: (IfaceStringLiteral, [IfExtName]) -> WithHsDocIdentifiers StringLiteral GhcRn
fromIfaceStringLiteralWithNames :: (IfaceStringLiteral, [IfExtName])
-> WithHsDocIdentifiers StringLiteral GhcRn
fromIfaceStringLiteralWithNames (IfaceStringLiteral
str, [IfExtName]
names) = StringLiteral
-> [Located (IdP GhcRn)]
-> WithHsDocIdentifiers StringLiteral GhcRn
forall a pass.
a -> [Located (IdP pass)] -> WithHsDocIdentifiers a pass
WithHsDocIdentifiers (IfaceStringLiteral -> StringLiteral
fromIfaceStringLiteral IfaceStringLiteral
str) ((IfExtName -> Located IfExtName)
-> [IfExtName] -> [Located IfExtName]
forall a b. (a -> b) -> [a] -> [b]
map IfExtName -> Located IfExtName
forall e. e -> Located e
noLoc [IfExtName]
names)
fromIfaceStringLiteral :: IfaceStringLiteral -> StringLiteral
fromIfaceStringLiteral :: IfaceStringLiteral -> StringLiteral
fromIfaceStringLiteral (IfStringLiteral SourceText
st FastString
fs) = SourceText
-> FastString -> Maybe NoCommentsLocation -> StringLiteral
StringLiteral SourceText
st FastString
fs Maybe NoCommentsLocation
forall a. Maybe a
Nothing
data IfaceExpr
= IfaceLcl IfLclName
| IfaceExt IfExtName
| IfaceType IfaceType
| IfaceCo IfaceCoercion
| IfaceTuple TupleSort [IfaceExpr]
| IfaceLam IfaceLamBndr IfaceExpr
| IfaceApp IfaceExpr IfaceExpr
| IfaceCase IfaceExpr IfLclName [IfaceAlt]
| IfaceECase IfaceExpr IfaceType
| IfaceLet (IfaceBinding IfaceLetBndr) IfaceExpr
| IfaceCast IfaceExpr IfaceCoercion
| IfaceLit Literal
| IfaceLitRubbish TypeOrConstraint IfaceType
| IfaceFCall ForeignCall IfaceType
| IfaceTick IfaceTickish IfaceExpr
data IfaceTickish
= IfaceHpcTick Module Int
| IfaceSCC CostCentre Bool Bool
| IfaceSource RealSrcSpan FastString
| IfaceBreakpoint Int [IfaceExpr] Module
data IfaceAlt = IfaceAlt IfaceConAlt [IfLclName] IfaceExpr
data IfaceConAlt = IfaceDefaultAlt
| IfaceDataAlt IfExtName
| IfaceLitAlt Literal
type IfaceBinding b = IfaceBindingX IfaceExpr b
data IfaceBindingX r b
= IfaceNonRec b r
| IfaceRec [(b, r)]
deriving ((forall a b. (a -> b) -> IfaceBindingX r a -> IfaceBindingX r b)
-> (forall a b. a -> IfaceBindingX r b -> IfaceBindingX r a)
-> Functor (IfaceBindingX r)
forall a b. a -> IfaceBindingX r b -> IfaceBindingX r a
forall a b. (a -> b) -> IfaceBindingX r a -> IfaceBindingX r b
forall r a b. a -> IfaceBindingX r b -> IfaceBindingX r a
forall r a b. (a -> b) -> IfaceBindingX r a -> IfaceBindingX r b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall r a b. (a -> b) -> IfaceBindingX r a -> IfaceBindingX r b
fmap :: forall a b. (a -> b) -> IfaceBindingX r a -> IfaceBindingX r b
$c<$ :: forall r a b. a -> IfaceBindingX r b -> IfaceBindingX r a
<$ :: forall a b. a -> IfaceBindingX r b -> IfaceBindingX r a
Functor, (forall m. Monoid m => IfaceBindingX r m -> m)
-> (forall m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m)
-> (forall m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m)
-> (forall a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b)
-> (forall a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b)
-> (forall b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b)
-> (forall b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b)
-> (forall a. (a -> a -> a) -> IfaceBindingX r a -> a)
-> (forall a. (a -> a -> a) -> IfaceBindingX r a -> a)
-> (forall a. IfaceBindingX r a -> [a])
-> (forall a. IfaceBindingX r a -> Bool)
-> (forall a. IfaceBindingX r a -> Int)
-> (forall a. Eq a => a -> IfaceBindingX r a -> Bool)
-> (forall a. Ord a => IfaceBindingX r a -> a)
-> (forall a. Ord a => IfaceBindingX r a -> a)
-> (forall a. Num a => IfaceBindingX r a -> a)
-> (forall a. Num a => IfaceBindingX r a -> a)
-> Foldable (IfaceBindingX r)
forall a. Eq a => a -> IfaceBindingX r a -> Bool
forall a. Num a => IfaceBindingX r a -> a
forall a. Ord a => IfaceBindingX r a -> a
forall m. Monoid m => IfaceBindingX r m -> m
forall a. IfaceBindingX r a -> Bool
forall a. IfaceBindingX r a -> Int
forall a. IfaceBindingX r a -> [a]
forall a. (a -> a -> a) -> IfaceBindingX r a -> a
forall r a. Eq a => a -> IfaceBindingX r a -> Bool
forall r a. Num a => IfaceBindingX r a -> a
forall r a. Ord a => IfaceBindingX r a -> a
forall r m. Monoid m => IfaceBindingX r m -> m
forall m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m
forall r a. IfaceBindingX r a -> Bool
forall r a. IfaceBindingX r a -> Int
forall r a. IfaceBindingX r a -> [a]
forall b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b
forall a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b
forall r a. (a -> a -> a) -> IfaceBindingX r a -> a
forall r m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m
forall r b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b
forall r a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall r m. Monoid m => IfaceBindingX r m -> m
fold :: forall m. Monoid m => IfaceBindingX r m -> m
$cfoldMap :: forall r m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m
$cfoldMap' :: forall r m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> IfaceBindingX r a -> m
$cfoldr :: forall r a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b
foldr :: forall a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b
$cfoldr' :: forall r a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> IfaceBindingX r a -> b
$cfoldl :: forall r b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b
foldl :: forall b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b
$cfoldl' :: forall r b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> IfaceBindingX r a -> b
$cfoldr1 :: forall r a. (a -> a -> a) -> IfaceBindingX r a -> a
foldr1 :: forall a. (a -> a -> a) -> IfaceBindingX r a -> a
$cfoldl1 :: forall r a. (a -> a -> a) -> IfaceBindingX r a -> a
foldl1 :: forall a. (a -> a -> a) -> IfaceBindingX r a -> a
$ctoList :: forall r a. IfaceBindingX r a -> [a]
toList :: forall a. IfaceBindingX r a -> [a]
$cnull :: forall r a. IfaceBindingX r a -> Bool
null :: forall a. IfaceBindingX r a -> Bool
$clength :: forall r a. IfaceBindingX r a -> Int
length :: forall a. IfaceBindingX r a -> Int
$celem :: forall r a. Eq a => a -> IfaceBindingX r a -> Bool
elem :: forall a. Eq a => a -> IfaceBindingX r a -> Bool
$cmaximum :: forall r a. Ord a => IfaceBindingX r a -> a
maximum :: forall a. Ord a => IfaceBindingX r a -> a
$cminimum :: forall r a. Ord a => IfaceBindingX r a -> a
minimum :: forall a. Ord a => IfaceBindingX r a -> a
$csum :: forall r a. Num a => IfaceBindingX r a -> a
sum :: forall a. Num a => IfaceBindingX r a -> a
$cproduct :: forall r a. Num a => IfaceBindingX r a -> a
product :: forall a. Num a => IfaceBindingX r a -> a
Foldable, Functor (IfaceBindingX r)
Foldable (IfaceBindingX r)
(Functor (IfaceBindingX r), Foldable (IfaceBindingX r)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IfaceBindingX r a -> f (IfaceBindingX r b))
-> (forall (f :: * -> *) a.
Applicative f =>
IfaceBindingX r (f a) -> f (IfaceBindingX r a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IfaceBindingX r a -> m (IfaceBindingX r b))
-> (forall (m :: * -> *) a.
Monad m =>
IfaceBindingX r (m a) -> m (IfaceBindingX r a))
-> Traversable (IfaceBindingX r)
forall r. Functor (IfaceBindingX r)
forall r. Foldable (IfaceBindingX r)
forall r (m :: * -> *) a.
Monad m =>
IfaceBindingX r (m a) -> m (IfaceBindingX r a)
forall r (f :: * -> *) a.
Applicative f =>
IfaceBindingX r (f a) -> f (IfaceBindingX r a)
forall r (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IfaceBindingX r a -> m (IfaceBindingX r b)
forall r (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IfaceBindingX r a -> f (IfaceBindingX r b)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
IfaceBindingX r (m a) -> m (IfaceBindingX r a)
forall (f :: * -> *) a.
Applicative f =>
IfaceBindingX r (f a) -> f (IfaceBindingX r a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IfaceBindingX r a -> m (IfaceBindingX r b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IfaceBindingX r a -> f (IfaceBindingX r b)
$ctraverse :: forall r (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IfaceBindingX r a -> f (IfaceBindingX r b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IfaceBindingX r a -> f (IfaceBindingX r b)
$csequenceA :: forall r (f :: * -> *) a.
Applicative f =>
IfaceBindingX r (f a) -> f (IfaceBindingX r a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
IfaceBindingX r (f a) -> f (IfaceBindingX r a)
$cmapM :: forall r (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IfaceBindingX r a -> m (IfaceBindingX r b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IfaceBindingX r a -> m (IfaceBindingX r b)
$csequence :: forall r (m :: * -> *) a.
Monad m =>
IfaceBindingX r (m a) -> m (IfaceBindingX r a)
sequence :: forall (m :: * -> *) a.
Monad m =>
IfaceBindingX r (m a) -> m (IfaceBindingX r a)
Traversable, Eq (IfaceBindingX r b)
Eq (IfaceBindingX r b) =>
(IfaceBindingX r b -> IfaceBindingX r b -> Ordering)
-> (IfaceBindingX r b -> IfaceBindingX r b -> Bool)
-> (IfaceBindingX r b -> IfaceBindingX r b -> Bool)
-> (IfaceBindingX r b -> IfaceBindingX r b -> Bool)
-> (IfaceBindingX r b -> IfaceBindingX r b -> Bool)
-> (IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b)
-> (IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b)
-> Ord (IfaceBindingX r b)
IfaceBindingX r b -> IfaceBindingX r b -> Bool
IfaceBindingX r b -> IfaceBindingX r b -> Ordering
IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall r b. (Ord b, Ord r) => Eq (IfaceBindingX r b)
forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Ordering
forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b
$ccompare :: forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Ordering
compare :: IfaceBindingX r b -> IfaceBindingX r b -> Ordering
$c< :: forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
< :: IfaceBindingX r b -> IfaceBindingX r b -> Bool
$c<= :: forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
<= :: IfaceBindingX r b -> IfaceBindingX r b -> Bool
$c> :: forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
> :: IfaceBindingX r b -> IfaceBindingX r b -> Bool
$c>= :: forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
>= :: IfaceBindingX r b -> IfaceBindingX r b -> Bool
$cmax :: forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b
max :: IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b
$cmin :: forall r b.
(Ord b, Ord r) =>
IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b
min :: IfaceBindingX r b -> IfaceBindingX r b -> IfaceBindingX r b
Ord, IfaceBindingX r b -> IfaceBindingX r b -> Bool
(IfaceBindingX r b -> IfaceBindingX r b -> Bool)
-> (IfaceBindingX r b -> IfaceBindingX r b -> Bool)
-> Eq (IfaceBindingX r b)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall r b.
(Eq b, Eq r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
$c== :: forall r b.
(Eq b, Eq r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
== :: IfaceBindingX r b -> IfaceBindingX r b -> Bool
$c/= :: forall r b.
(Eq b, Eq r) =>
IfaceBindingX r b -> IfaceBindingX r b -> Bool
/= :: IfaceBindingX r b -> IfaceBindingX r b -> Bool
Eq)
data IfaceLetBndr = IfLetBndr IfLclName IfaceType IfaceIdInfo JoinPointHood
data IfaceTopBndrInfo = IfLclTopBndr IfLclName IfaceType IfaceIdInfo IfaceIdDetails
| IfGblTopBndr IfaceTopBndr
data IfaceMaybeRhs = IfUseUnfoldingRhs | IfRhs IfaceExpr
pprAxBranch :: SDoc -> BranchIndex -> IfaceAxBranch -> SDoc
pprAxBranch :: SDoc -> Int -> IfaceAxBranch -> SDoc
pprAxBranch SDoc
pp_tc Int
idx (IfaceAxBranch { ifaxbTyVars :: IfaceAxBranch -> [IfaceTvBndr]
ifaxbTyVars = [IfaceTvBndr]
tvs
, ifaxbCoVars :: IfaceAxBranch -> [IfaceIdBndr]
ifaxbCoVars = [IfaceIdBndr]
_cvs
, ifaxbLHS :: IfaceAxBranch -> IfaceAppArgs
ifaxbLHS = IfaceAppArgs
pat_tys
, ifaxbRHS :: IfaceAxBranch -> IfaceType
ifaxbRHS = IfaceType
rhs
, ifaxbIncomps :: IfaceAxBranch -> [Int]
ifaxbIncomps = [Int]
incomps })
= Bool -> SDoc -> SDoc -> SDoc
forall a. HasCallStack => Bool -> SDoc -> a -> a
assertPpr ([IfaceIdBndr] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceIdBndr]
_cvs) (SDoc
pp_tc SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ [IfaceIdBndr] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IfaceIdBndr]
_cvs) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
SDoc -> Int -> SDoc -> SDoc
hang SDoc
ppr_binders Int
2 (SDoc -> Int -> SDoc -> SDoc
hang SDoc
pp_lhs Int
2 (SDoc
forall doc. IsLine doc => doc
equals SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
rhs))
SDoc -> SDoc -> SDoc
$+$
Int -> SDoc -> SDoc
nest Int
4 SDoc
maybe_incomps
where
ppr_binders :: SDoc
ppr_binders = SDoc
maybe_index SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
[IfaceForAllBndr] -> SDoc
pprUserIfaceForAll ((IfaceTvBndr -> IfaceForAllBndr)
-> [IfaceTvBndr] -> [IfaceForAllBndr]
forall a b. (a -> b) -> [a] -> [b]
map (ForAllTyFlag -> IfaceTvBndr -> IfaceForAllBndr
mkIfaceForAllTvBndr ForAllTyFlag
Specified) [IfaceTvBndr]
tvs)
pp_lhs :: SDoc
pp_lhs = SDoc -> Int -> SDoc -> SDoc
hang SDoc
pp_tc Int
2 (IfaceAppArgs -> SDoc
pprParendIfaceAppArgs IfaceAppArgs
pat_tys)
maybe_index :: SDoc
maybe_index
= (SDocContext -> Bool) -> SDoc -> SDoc
ppWhenOption SDocContext -> Bool
sdocPrintAxiomIncomps (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"{-" 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
<> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
idx) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"-}"
maybe_incomps :: SDoc
maybe_incomps
= (SDocContext -> Bool) -> SDoc -> SDoc
ppWhenOption SDocContext -> Bool
sdocPrintAxiomIncomps (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen ([Int] -> Bool
forall (f :: * -> *) a. Foldable f => f a -> Bool
notNull [Int]
incomps) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"--" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"incompatible with:"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (Int -> SDoc) -> [Int] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (\Int
incomp -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"#" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
incomp) [Int]
incomps
instance Outputable IfaceWarnings where
ppr :: IfaceWarnings -> SDoc
ppr = \case
IfWarnAll IfaceWarningTxt
txt -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Warn all" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceWarningTxt -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceWarningTxt
txt
IfWarnSome [(OccName, IfaceWarningTxt)]
vs [(IfExtName, IfaceWarningTxt)]
ds ->
SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Warnings:") Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Deprecated names:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
name SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceWarningTxt -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceWarningTxt
txt | (OccName
name, IfaceWarningTxt
txt) <- [(OccName, IfaceWarningTxt)]
vs] SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Deprecated exports:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
name SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceWarningTxt -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceWarningTxt
txt | (IfExtName
name, IfaceWarningTxt
txt) <- [(IfExtName, IfaceWarningTxt)]
ds]
instance Outputable IfaceWarningTxt where
ppr :: IfaceWarningTxt -> SDoc
ppr = \case
IfWarningTxt Maybe WarningCategory
_ SourceText
_ [(IfaceStringLiteral, [IfExtName])]
ws -> [(IfaceStringLiteral, [IfExtName])] -> SDoc
pp_ws [(IfaceStringLiteral, [IfExtName])]
ws
IfDeprecatedTxt SourceText
_ [(IfaceStringLiteral, [IfExtName])]
ds -> [(IfaceStringLiteral, [IfExtName])] -> SDoc
pp_ws [(IfaceStringLiteral, [IfExtName])]
ds
where
pp_ws :: [(IfaceStringLiteral, [IfExtName])] -> SDoc
pp_ws [(IfaceStringLiteral, [IfExtName])
msg] = (IfaceStringLiteral, [IfExtName]) -> SDoc
forall {b}. (IfaceStringLiteral, b) -> SDoc
pp_with_name (IfaceStringLiteral, [IfExtName])
msg
pp_ws [(IfaceStringLiteral, [IfExtName])]
msgs = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ([SDoc] -> SDoc)
-> ([(IfaceStringLiteral, [IfExtName])] -> [SDoc])
-> [(IfaceStringLiteral, [IfExtName])]
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
comma ([SDoc] -> [SDoc])
-> ([(IfaceStringLiteral, [IfExtName])] -> [SDoc])
-> [(IfaceStringLiteral, [IfExtName])]
-> [SDoc]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((IfaceStringLiteral, [IfExtName]) -> SDoc)
-> [(IfaceStringLiteral, [IfExtName])] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (IfaceStringLiteral, [IfExtName]) -> SDoc
forall {b}. (IfaceStringLiteral, b) -> SDoc
pp_with_name ([(IfaceStringLiteral, [IfExtName])] -> SDoc)
-> [(IfaceStringLiteral, [IfExtName])] -> SDoc
forall a b. (a -> b) -> a -> b
$ [(IfaceStringLiteral, [IfExtName])]
msgs
pp_with_name :: (IfaceStringLiteral, b) -> SDoc
pp_with_name = IfaceStringLiteral -> SDoc
forall a. Outputable a => a -> SDoc
ppr (IfaceStringLiteral -> SDoc)
-> ((IfaceStringLiteral, b) -> IfaceStringLiteral)
-> (IfaceStringLiteral, b)
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IfaceStringLiteral, b) -> IfaceStringLiteral
forall a b. (a, b) -> a
fst
instance Outputable IfaceStringLiteral where
ppr :: IfaceStringLiteral -> SDoc
ppr (IfStringLiteral SourceText
st FastString
fs) = SourceText -> SDoc -> SDoc
pprWithSourceText SourceText
st (FastString -> SDoc
forall doc. IsLine doc => FastString -> doc
ftext FastString
fs)
instance Outputable IfaceAnnotation where
ppr :: IfaceAnnotation -> SDoc
ppr (IfaceAnnotation IfaceAnnTarget
target AnnPayload
value) = IfaceAnnTarget -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceAnnTarget
target SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
forall doc. IsLine doc => doc
colon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> AnnPayload -> SDoc
forall a. Outputable a => a -> SDoc
ppr AnnPayload
value
instance NamedThing IfaceClassOp where
getName :: IfaceClassOp -> IfExtName
getName (IfaceClassOp IfExtName
n IfaceType
_ Maybe (DefMethSpec IfaceType)
_) = IfExtName
n
instance HasOccName IfaceClassOp where
occName :: IfaceClassOp -> OccName
occName = IfaceClassOp -> OccName
forall a. NamedThing a => a -> OccName
getOccName
instance NamedThing IfaceConDecl where
getName :: IfaceConDecl -> IfExtName
getName = IfaceConDecl -> IfExtName
ifConName
instance HasOccName IfaceConDecl where
occName :: IfaceConDecl -> OccName
occName = IfaceConDecl -> OccName
forall a. NamedThing a => a -> OccName
getOccName
instance NamedThing IfaceDecl where
getName :: IfaceDecl -> IfExtName
getName = IfaceDecl -> IfExtName
ifName
instance HasOccName IfaceDecl where
occName :: IfaceDecl -> OccName
occName = IfaceDecl -> OccName
forall a. NamedThing a => a -> OccName
getOccName
instance Outputable IfaceDecl where
ppr :: IfaceDecl -> SDoc
ppr = ShowSub -> IfaceDecl -> SDoc
pprIfaceDecl ShowSub
showToIface
instance (Outputable r, Outputable b) => Outputable (IfaceBindingX r b) where
ppr :: IfaceBindingX r b -> SDoc
ppr IfaceBindingX r b
b = case IfaceBindingX r b
b of
(IfaceNonRec b
b r
r) -> (b, r) -> SDoc
forall {a} {a}. (Outputable a, Outputable a) => (a, a) -> SDoc
ppr_bind (b
b, r
r)
(IfaceRec [(b, r)]
pairs) -> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"rec {", Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep (((b, r) -> SDoc) -> [(b, r)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (b, r) -> SDoc
forall {a} {a}. (Outputable a, Outputable a) => (a, a) -> SDoc
ppr_bind [(b, r)]
pairs)),String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"}"]
where
ppr_bind :: (a, a) -> SDoc
ppr_bind (a
b, a
r) = a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
b 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
<+> a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
r
instance Outputable IfaceTopBndrInfo where
ppr :: IfaceTopBndrInfo -> SDoc
ppr (IfLclTopBndr IfLclName
lcl_name IfaceType
_ IfaceIdInfo
_ IfaceIdDetails
_) = IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
lcl_name
ppr (IfGblTopBndr IfExtName
gbl) = IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
gbl
instance Outputable IfaceMaybeRhs where
ppr :: IfaceMaybeRhs -> SDoc
ppr IfaceMaybeRhs
IfUseUnfoldingRhs = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"<unfolding>"
ppr (IfRhs IfaceExpr
ie) = IfaceExpr -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceExpr
ie
showToHeader :: ShowSub
= ShowSub { ss_how_much :: ShowHowMuch
ss_how_much = AltPpr -> ShowHowMuch
ShowHeader (AltPpr -> ShowHowMuch) -> AltPpr -> ShowHowMuch
forall a b. (a -> b) -> a -> b
$ Maybe (OccName -> SDoc) -> AltPpr
AltPpr Maybe (OccName -> SDoc)
forall a. Maybe a
Nothing
, ss_forall :: ShowForAllFlag
ss_forall = ShowForAllFlag
ShowForAllWhen }
showToIface :: ShowSub
showToIface :: ShowSub
showToIface = ShowSub { ss_how_much :: ShowHowMuch
ss_how_much = ShowHowMuch
ShowIface
, ss_forall :: ShowForAllFlag
ss_forall = ShowForAllFlag
ShowForAllWhen }
ppShowIface :: ShowSub -> SDoc -> SDoc
ppShowIface :: ShowSub -> SDoc -> SDoc
ppShowIface (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowHowMuch
ShowIface }) SDoc
doc = SDoc
doc
ppShowIface ShowSub
_ SDoc
_ = SDoc
forall doc. IsOutput doc => doc
Outputable.empty
ppShowAllSubs :: ShowSub -> SDoc -> SDoc
ppShowAllSubs :: ShowSub -> SDoc -> SDoc
ppShowAllSubs (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowSome Maybe (OccName -> Bool)
Nothing AltPpr
_ }) SDoc
doc
= SDoc
doc
ppShowAllSubs (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowHowMuch
ShowIface }) SDoc
doc = SDoc
doc
ppShowAllSubs ShowSub
_ SDoc
_ = SDoc
forall doc. IsOutput doc => doc
Outputable.empty
ppShowRhs :: ShowSub -> SDoc -> SDoc
ppShowRhs :: ShowSub -> SDoc -> SDoc
ppShowRhs (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowHeader AltPpr
_ }) SDoc
_ = SDoc
forall doc. IsOutput doc => doc
Outputable.empty
ppShowRhs ShowSub
_ SDoc
doc = SDoc
doc
showSub :: HasOccName n => ShowSub -> n -> Bool
showSub :: forall n. HasOccName n => ShowSub -> n -> Bool
showSub (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowHeader AltPpr
_ }) n
_ = Bool
False
showSub (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowSome (Just OccName -> Bool
f) AltPpr
_ }) n
thing
= OccName -> Bool
f (n -> OccName
forall name. HasOccName name => name -> OccName
occName n
thing)
showSub (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowHowMuch
_ }) n
_ = Bool
True
ppr_trim :: [Maybe SDoc] -> [SDoc]
ppr_trim :: [Maybe SDoc] -> [SDoc]
ppr_trim [Maybe SDoc]
xs
= (Bool, [SDoc]) -> [SDoc]
forall a b. (a, b) -> b
snd ((Maybe SDoc -> (Bool, [SDoc]) -> (Bool, [SDoc]))
-> (Bool, [SDoc]) -> [Maybe SDoc] -> (Bool, [SDoc])
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Maybe SDoc -> (Bool, [SDoc]) -> (Bool, [SDoc])
forall {a}. IsLine a => Maybe a -> (Bool, [a]) -> (Bool, [a])
go (Bool
False, []) [Maybe SDoc]
xs)
where
go :: Maybe a -> (Bool, [a]) -> (Bool, [a])
go (Just a
doc) (Bool
_, [a]
so_far) = (Bool
False, a
doc a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
so_far)
go Maybe a
Nothing (Bool
True, [a]
so_far) = (Bool
True, [a]
so_far)
go Maybe a
Nothing (Bool
False, [a]
so_far) = (Bool
True, String -> a
forall doc. IsLine doc => String -> doc
text String
"..." a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
so_far)
isIfaceDataInstance :: IfaceTyConParent -> Bool
isIfaceDataInstance :: IfaceTyConParent -> Bool
isIfaceDataInstance IfaceTyConParent
IfNoParent = Bool
False
isIfaceDataInstance IfaceTyConParent
_ = Bool
True
pprClassRoles :: ShowSub -> IfaceTopBndr -> [IfaceTyConBinder] -> [Role] -> SDoc
pprClassRoles :: ShowSub -> IfExtName -> [IfaceTyConBinder] -> [Role] -> SDoc
pprClassRoles ShowSub
ss IfExtName
clas [IfaceTyConBinder]
binders [Role]
roles =
(Role -> Bool) -> SDoc -> [IfaceTyConBinder] -> [Role] -> SDoc
pprRoles (Role -> Role -> Bool
forall a. Eq a => a -> a -> Bool
== Role
Nominal)
(ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
clas))
[IfaceTyConBinder]
binders
[Role]
roles
pprClassStandaloneKindSig :: ShowSub -> IfaceTopBndr -> IfaceKind -> SDoc
pprClassStandaloneKindSig :: ShowSub -> IfExtName -> IfaceType -> SDoc
pprClassStandaloneKindSig ShowSub
ss IfExtName
clas =
SDoc -> IfaceType -> SDoc
pprStandaloneKindSig (ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
clas))
constraintIfaceKind :: IfaceKind
constraintIfaceKind :: IfaceType
constraintIfaceKind =
IfaceTyCon -> IfaceAppArgs -> IfaceType
IfaceTyConApp (IfExtName -> IfaceTyConInfo -> IfaceTyCon
IfaceTyCon IfExtName
constraintKindTyConName (PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo
mkIfaceTyConInfo PromotionFlag
NotPromoted IfaceTyConSort
IfaceNormalTyCon)) IfaceAppArgs
IA_Nil
pprIfaceDecl :: ShowSub -> IfaceDecl -> SDoc
pprIfaceDecl :: ShowSub -> IfaceDecl -> SDoc
pprIfaceDecl ShowSub
ss (IfaceData { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
tycon, ifCType :: IfaceDecl -> Maybe CType
ifCType = Maybe CType
ctype,
ifCtxt :: IfaceDecl -> IfaceContext
ifCtxt = IfaceContext
context, ifResKind :: IfaceDecl -> IfaceType
ifResKind = IfaceType
kind,
ifRoles :: IfaceDecl -> [Role]
ifRoles = [Role]
roles, ifCons :: IfaceDecl -> IfaceConDecls
ifCons = IfaceConDecls
condecls,
ifParent :: IfaceDecl -> IfaceTyConParent
ifParent = IfaceTyConParent
parent,
ifGadtSyntax :: IfaceDecl -> Bool
ifGadtSyntax = Bool
gadt,
ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
binders })
| Bool
gadt = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
pp_roles
, SDoc
pp_ki_sig
, SDoc
pp_nd SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_lhs 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_where
, Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [SDoc]
pp_cons)
, Int -> SDoc -> SDoc
nest Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss SDoc
pp_extra ]
| Bool
otherwise = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
pp_roles
, SDoc
pp_ki_sig
, SDoc -> Int -> SDoc -> SDoc
hang (SDoc
pp_nd SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_lhs) Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
add_bars [SDoc]
pp_cons)
, Int -> SDoc -> SDoc
nest Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss SDoc
pp_extra ]
where
is_data_instance :: Bool
is_data_instance = IfaceTyConParent -> Bool
isIfaceDataInstance IfaceTyConParent
parent
pp_data_inst_forall :: SDoc
pp_data_inst_forall :: SDoc
pp_data_inst_forall = [IfaceForAllBndr] -> SDoc
pprUserIfaceForAll [IfaceForAllBndr]
forall_bndrs
forall_bndrs :: [IfaceForAllBndr]
forall_bndrs :: [IfaceForAllBndr]
forall_bndrs = [IfaceBndr -> ForAllTyFlag -> IfaceForAllBndr
forall var argf. var -> argf -> VarBndr var argf
Bndr (IfaceTyConBinder -> IfaceBndr
forall tv argf. VarBndr tv argf -> tv
binderVar IfaceTyConBinder
tc_bndr) ForAllTyFlag
Specified | IfaceTyConBinder
tc_bndr <- [IfaceTyConBinder]
binders]
cons :: [IfaceConDecl]
cons = IfaceConDecls -> [IfaceConDecl]
visibleIfConDecls IfaceConDecls
condecls
pp_where :: SDoc
pp_where = Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen (Bool
gadt Bool -> Bool -> Bool
&& Bool -> Bool
not ([IfaceConDecl] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceConDecl]
cons)) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where"
pp_cons :: [SDoc]
pp_cons = [Maybe SDoc] -> [SDoc]
ppr_trim ((IfaceConDecl -> Maybe SDoc) -> [IfaceConDecl] -> [Maybe SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceConDecl -> Maybe SDoc
show_con [IfaceConDecl]
cons) :: [SDoc]
pp_kind :: SDoc
pp_kind = Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless (Bool
ki_sig_printable Bool -> Bool -> Bool
|| IfaceType -> Bool
isIfaceLiftedTypeKind IfaceType
kind)
(SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
kind)
pp_lhs :: SDoc
pp_lhs = case IfaceTyConParent
parent of
IfaceTyConParent
IfNoParent -> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig IfaceContext
context ShowSub
ss IfExtName
tycon [IfaceTyConBinder]
binders
IfDataInstance{}
-> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"instance" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_data_inst_forall
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceTyConParent -> SDoc
pprIfaceTyConParent IfaceTyConParent
parent
pp_roles :: SDoc
pp_roles
| Bool
is_data_instance = SDoc
forall doc. IsOutput doc => doc
empty
| Bool
otherwise = (Role -> Bool) -> SDoc -> [IfaceTyConBinder] -> [Role] -> SDoc
pprRoles (Role -> Role -> Bool
forall a. Eq a => a -> a -> Bool
== Role
Representational) SDoc
name_doc [IfaceTyConBinder]
binders [Role]
roles
ki_sig_printable :: Bool
ki_sig_printable =
Bool -> Bool
not Bool
is_data_instance
pp_ki_sig :: SDoc
pp_ki_sig = Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen Bool
ki_sig_printable (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
name_doc ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
kind)
suppress_bndr_sig :: SuppressBndrSig
suppress_bndr_sig = Bool -> SuppressBndrSig
SuppressBndrSig Bool
ki_sig_printable
name_doc :: SDoc
name_doc = ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
tycon)
add_bars :: [doc] -> doc
add_bars [] = doc
forall doc. IsOutput doc => doc
Outputable.empty
add_bars (doc
c:[doc]
cs) = [doc] -> doc
forall doc. IsLine doc => [doc] -> doc
sep ((doc
forall doc. IsLine doc => doc
equals doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<+> doc
c) doc -> [doc] -> [doc]
forall a. a -> [a] -> [a]
: (doc -> doc) -> [doc] -> [doc]
forall a b. (a -> b) -> [a] -> [b]
map (doc
forall doc. IsLine doc => doc
vbar doc -> doc -> doc
forall doc. IsLine doc => doc -> doc -> doc
<+>) [doc]
cs)
ok_con :: IfaceConDecl -> Bool
ok_con IfaceConDecl
dc = ShowSub -> IfaceConDecl -> Bool
forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfaceConDecl
dc Bool -> Bool -> Bool
|| (FieldLabel -> Bool) -> [FieldLabel] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (ShowSub -> IfExtName -> Bool
forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss (IfExtName -> Bool)
-> (FieldLabel -> IfExtName) -> FieldLabel -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FieldLabel -> IfExtName
flSelector) (IfaceConDecl -> [FieldLabel]
ifConFields IfaceConDecl
dc)
show_con :: IfaceConDecl -> Maybe SDoc
show_con IfaceConDecl
dc
| IfaceConDecl -> Bool
ok_con IfaceConDecl
dc = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (SDoc -> Maybe SDoc) -> SDoc -> Maybe SDoc
forall a b. (a -> b) -> a -> b
$ ShowSub
-> Bool
-> IfExtName
-> [IfaceTyConBinder]
-> IfaceTyConParent
-> IfaceConDecl
-> SDoc
pprIfaceConDecl ShowSub
ss Bool
gadt IfExtName
tycon [IfaceTyConBinder]
binders IfaceTyConParent
parent IfaceConDecl
dc
| Bool
otherwise = Maybe SDoc
forall a. Maybe a
Nothing
pp_nd :: SDoc
pp_nd = case IfaceConDecls
condecls of
IfAbstractTyCon{} -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"data"
IfDataTyCon Bool
True [IfaceConDecl]
_ -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type data"
IfDataTyCon{} -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"data"
IfNewTyCon{} -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"newtype"
pp_extra :: SDoc
pp_extra = [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [Maybe CType -> SDoc
pprCType Maybe CType
ctype]
pprIfaceDecl ShowSub
ss (IfaceClass { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
clas
, ifRoles :: IfaceDecl -> [Role]
ifRoles = [Role]
roles
, ifFDs :: IfaceDecl -> [FunDep IfLclName]
ifFDs = [FunDep IfLclName]
fds
, ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
binders
, ifBody :: IfaceDecl -> IfaceClassBody
ifBody = IfaceClassBody
IfAbstractClass })
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ ShowSub -> IfExtName -> [IfaceTyConBinder] -> [Role] -> SDoc
pprClassRoles ShowSub
ss IfExtName
clas [IfaceTyConBinder]
binders [Role]
roles
, ShowSub -> IfExtName -> IfaceType -> SDoc
pprClassStandaloneKindSig ShowSub
ss IfExtName
clas ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
constraintIfaceKind)
, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"class" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
clas [IfaceTyConBinder]
binders SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [FunDep IfLclName] -> SDoc
forall a. Outputable a => [FunDep a] -> SDoc
pprFundeps [FunDep IfLclName]
fds ]
where
suppress_bndr_sig :: SuppressBndrSig
suppress_bndr_sig = Bool -> SuppressBndrSig
SuppressBndrSig Bool
True
pprIfaceDecl ShowSub
ss (IfaceClass { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
clas
, ifRoles :: IfaceDecl -> [Role]
ifRoles = [Role]
roles
, ifFDs :: IfaceDecl -> [FunDep IfLclName]
ifFDs = [FunDep IfLclName]
fds
, ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
binders
, ifBody :: IfaceDecl -> IfaceClassBody
ifBody = IfConcreteClass {
ifATs :: IfaceClassBody -> [IfaceAT]
ifATs = [IfaceAT]
ats,
ifSigs :: IfaceClassBody -> [IfaceClassOp]
ifSigs = [IfaceClassOp]
sigs,
ifClassCtxt :: IfaceClassBody -> IfaceContext
ifClassCtxt = IfaceContext
context,
ifMinDef :: IfaceClassBody -> IfaceBooleanFormula
ifMinDef = IfaceBooleanFormula
minDef
}})
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ ShowSub -> IfExtName -> [IfaceTyConBinder] -> [Role] -> SDoc
pprClassRoles ShowSub
ss IfExtName
clas [IfaceTyConBinder]
binders [Role]
roles
, ShowSub -> IfExtName -> IfaceType -> SDoc
pprClassStandaloneKindSig ShowSub
ss IfExtName
clas ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
constraintIfaceKind)
, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"class" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig IfaceContext
context ShowSub
ss IfExtName
clas [IfaceTyConBinder]
binders SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [FunDep IfLclName] -> SDoc
forall a. Outputable a => [FunDep a] -> SDoc
pprFundeps [FunDep IfLclName]
fds SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_where
, Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [SDoc]
asocs, [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [SDoc]
dsigs
, ShowSub -> SDoc -> SDoc
ppShowAllSubs ShowSub
ss (BooleanFormula IfLclName -> SDoc
pprMinDef (BooleanFormula IfLclName -> SDoc)
-> BooleanFormula IfLclName -> SDoc
forall a b. (a -> b) -> a -> b
$ IfaceBooleanFormula -> BooleanFormula IfLclName
fromIfaceBooleanFormula IfaceBooleanFormula
minDef)])]
where
pp_where :: SDoc
pp_where = ShowSub -> SDoc -> SDoc
ppShowRhs ShowSub
ss (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless ([IfaceClassOp] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceClassOp]
sigs Bool -> Bool -> Bool
&& [IfaceAT] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceAT]
ats) (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"where")
asocs :: [SDoc]
asocs = [Maybe SDoc] -> [SDoc]
ppr_trim ([Maybe SDoc] -> [SDoc]) -> [Maybe SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ (IfaceAT -> Maybe SDoc) -> [IfaceAT] -> [Maybe SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceAT -> Maybe SDoc
maybeShowAssoc [IfaceAT]
ats
dsigs :: [SDoc]
dsigs = [Maybe SDoc] -> [SDoc]
ppr_trim ([Maybe SDoc] -> [SDoc]) -> [Maybe SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ (IfaceClassOp -> Maybe SDoc) -> [IfaceClassOp] -> [Maybe SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceClassOp -> Maybe SDoc
maybeShowSig [IfaceClassOp]
sigs
maybeShowAssoc :: IfaceAT -> Maybe SDoc
maybeShowAssoc :: IfaceAT -> Maybe SDoc
maybeShowAssoc asc :: IfaceAT
asc@(IfaceAT IfaceDecl
d Maybe IfaceType
_)
| ShowSub -> IfaceDecl -> Bool
forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfaceDecl
d = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (SDoc -> Maybe SDoc) -> SDoc -> Maybe SDoc
forall a b. (a -> b) -> a -> b
$ ShowSub -> IfaceAT -> SDoc
pprIfaceAT ShowSub
ss IfaceAT
asc
| Bool
otherwise = Maybe SDoc
forall a. Maybe a
Nothing
maybeShowSig :: IfaceClassOp -> Maybe SDoc
maybeShowSig :: IfaceClassOp -> Maybe SDoc
maybeShowSig IfaceClassOp
sg
| ShowSub -> IfaceClassOp -> Bool
forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfaceClassOp
sg = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (SDoc -> Maybe SDoc) -> SDoc -> Maybe SDoc
forall a b. (a -> b) -> a -> b
$ ShowSub -> IfaceClassOp -> SDoc
pprIfaceClassOp ShowSub
ss IfaceClassOp
sg
| Bool
otherwise = Maybe SDoc
forall a. Maybe a
Nothing
pprMinDef :: BooleanFormula IfLclName -> SDoc
pprMinDef :: BooleanFormula IfLclName -> SDoc
pprMinDef BooleanFormula IfLclName
minDef = Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless (BooleanFormula IfLclName -> Bool
forall a. BooleanFormula a -> Bool
isTrue BooleanFormula IfLclName
minDef) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"{-# MINIMAL" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
(Rational -> FastString -> SDoc)
-> Rational -> BooleanFormula FastString -> SDoc
forall a.
(Rational -> a -> SDoc) -> Rational -> BooleanFormula a -> SDoc
pprBooleanFormula
(\Rational
_ FastString
def -> Bool -> SDoc -> SDoc
cparen (FastString -> Bool
isLexSym FastString
def) (FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
def)) Rational
0 ((IfLclName -> FastString)
-> BooleanFormula IfLclName -> BooleanFormula FastString
forall a b. (a -> b) -> BooleanFormula a -> BooleanFormula b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IfLclName -> FastString
ifLclNameFS BooleanFormula IfLclName
minDef) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"#-}"
suppress_bndr_sig :: SuppressBndrSig
suppress_bndr_sig = Bool -> SuppressBndrSig
SuppressBndrSig Bool
True
pprIfaceDecl ShowSub
ss (IfaceSynonym { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
tc
, ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
binders
, ifSynRhs :: IfaceDecl -> IfaceType
ifSynRhs = IfaceType
mono_ty
, ifResKind :: IfaceDecl -> IfaceType
ifResKind = IfaceType
res_kind})
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
name_doc ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
res_kind)
, 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
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
tc [IfaceTyConBinder]
binders SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
forall doc. IsLine doc => doc
equals)
Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ [IfaceForAllBndr] -> SDoc
pprIfaceForAll [IfaceForAllBndr]
tvs, IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
theta, SDoc
ppr_tau
, Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless (IfaceType -> Bool
isIfaceLiftedTypeKind IfaceType
res_kind) (SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
res_kind) ])
]
where
([IfaceForAllBndr]
tvs, IfaceContext
theta, IfaceType
tau) = IfaceType -> ([IfaceForAllBndr], IfaceContext, IfaceType)
splitIfaceSigmaTy IfaceType
mono_ty
name_doc :: SDoc
name_doc = ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
tc)
ppr_tau :: SDoc
ppr_tau | IfExtName
tc IfExtName -> Unique -> Bool
forall a. Uniquable a => a -> Unique -> Bool
`hasKey` Unique
liftedTypeKindTyConKey Bool -> Bool -> Bool
||
IfExtName
tc IfExtName -> Unique -> Bool
forall a. Uniquable a => a -> Unique -> Bool
`hasKey` Unique
unrestrictedFunTyConKey Bool -> Bool -> Bool
||
IfExtName
tc IfExtName -> Unique -> Bool
forall a. Uniquable a => a -> Unique -> Bool
`hasKey` Unique
constraintKindTyConKey
= (SDocContext -> SDocContext) -> SDoc -> SDoc
updSDocContext (\SDocContext
ctx -> SDocContext
ctx { sdocPrintTypeAbbreviations = False }) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
tau
| Bool
otherwise = IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
tau
suppress_bndr_sig :: SuppressBndrSig
suppress_bndr_sig = Bool -> SuppressBndrSig
SuppressBndrSig Bool
True
pprIfaceDecl ShowSub
ss (IfaceFamily { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
tycon
, ifFamFlav :: IfaceDecl -> IfaceFamTyConFlav
ifFamFlav = IfaceFamTyConFlav
rhs, ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
binders
, ifResKind :: IfaceDecl -> IfaceType
ifResKind = IfaceType
res_kind
, ifResVar :: IfaceDecl -> Maybe IfLclName
ifResVar = Maybe IfLclName
res_var, ifFamInj :: IfaceDecl -> Injectivity
ifFamInj = Injectivity
inj })
| IfaceFamTyConFlav
IfaceDataFamilyTyCon <- IfaceFamTyConFlav
rhs
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
name_doc ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
res_kind)
, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"data family" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
tycon [IfaceTyConBinder]
binders
]
| Bool
otherwise
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
name_doc ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
res_kind)
, SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type family"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
tycon [IfaceTyConBinder]
binders
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe IfLclName -> Injectivity -> SDoc
pp_inj Maybe IfLclName
res_var Injectivity
inj
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> ShowSub -> SDoc -> SDoc
ppShowRhs ShowSub
ss (IfaceFamTyConFlav -> SDoc
forall {doc}. IsLine doc => IfaceFamTyConFlav -> doc
pp_where IfaceFamTyConFlav
rhs))
Int
2 (ShowSub -> SDoc -> SDoc
ppShowRhs ShowSub
ss (IfaceFamTyConFlav -> SDoc
pp_rhs IfaceFamTyConFlav
rhs))
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$
Int -> SDoc -> SDoc
nest Int
2 (ShowSub -> SDoc -> SDoc
ppShowRhs ShowSub
ss (IfaceFamTyConFlav -> SDoc
pp_branches IfaceFamTyConFlav
rhs))
]
where
name_doc :: SDoc
name_doc = ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
tycon)
pp_where :: IfaceFamTyConFlav -> doc
pp_where (IfaceClosedSynFamilyTyCon {}) = String -> doc
forall doc. IsLine doc => String -> doc
text String
"where"
pp_where IfaceFamTyConFlav
_ = doc
forall doc. IsOutput doc => doc
empty
pp_inj :: Maybe IfLclName -> Injectivity -> SDoc
pp_inj Maybe IfLclName
Nothing Injectivity
_ = SDoc
forall doc. IsOutput doc => doc
empty
pp_inj (Just IfLclName
res) Injectivity
inj
| Injective [Bool]
injectivity <- Injectivity
inj = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ SDoc
forall doc. IsLine doc => doc
equals, IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
res
, IfLclName -> [Bool] -> SDoc
pp_inj_cond IfLclName
res [Bool]
injectivity]
| Bool
otherwise = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ SDoc
forall doc. IsLine doc => doc
equals, IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
res ]
pp_inj_cond :: IfLclName -> [Bool] -> SDoc
pp_inj_cond IfLclName
res [Bool]
inj = case [Bool] -> [IfaceTyConBinder] -> [IfaceTyConBinder]
forall a. [Bool] -> [a] -> [a]
filterByList [Bool]
inj [IfaceTyConBinder]
binders of
[] -> SDoc
forall doc. IsOutput doc => doc
empty
[IfaceTyConBinder]
tvs -> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [SDoc
forall doc. IsLine doc => doc
vbar, IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
res, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"->", [IfLclName] -> SDoc
forall a. Outputable a => [a] -> SDoc
interppSP ((IfaceTyConBinder -> IfLclName)
-> [IfaceTyConBinder] -> [IfLclName]
forall a b. (a -> b) -> [a] -> [b]
map IfaceTyConBinder -> IfLclName
ifTyConBinderName [IfaceTyConBinder]
tvs)]
pp_rhs :: IfaceFamTyConFlav -> SDoc
pp_rhs IfaceFamTyConFlav
IfaceDataFamilyTyCon
= ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"data")
pp_rhs IfaceFamTyConFlav
IfaceOpenSynFamilyTyCon
= ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"open")
pp_rhs IfaceFamTyConFlav
IfaceAbstractClosedSynFamilyTyCon
= ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"closed, abstract")
pp_rhs (IfaceClosedSynFamilyTyCon {})
= SDoc
forall doc. IsOutput doc => doc
empty
pp_rhs IfaceFamTyConFlav
IfaceBuiltInSynFamTyCon
= ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"built-in")
pp_branches :: IfaceFamTyConFlav -> SDoc
pp_branches (IfaceClosedSynFamilyTyCon (Just (IfExtName
ax, [IfaceAxBranch]
brs)))
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ((Int -> IfaceAxBranch -> SDoc) -> [(Int, IfaceAxBranch)] -> [SDoc]
forall a b c. (a -> b -> c) -> [(a, b)] -> [c]
unzipWith (SDoc -> Int -> IfaceAxBranch -> SDoc
pprAxBranch
(ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr
(ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss)
(IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
tycon))
) ([(Int, IfaceAxBranch)] -> [SDoc])
-> [(Int, IfaceAxBranch)] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ [Int] -> [IfaceAxBranch] -> [(Int, IfaceAxBranch)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0..] [IfaceAxBranch]
brs)
SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"axiom" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
ax)
pp_branches IfaceFamTyConFlav
_ = SDoc
forall doc. IsOutput doc => doc
Outputable.empty
suppress_bndr_sig :: SuppressBndrSig
suppress_bndr_sig = Bool -> SuppressBndrSig
SuppressBndrSig Bool
True
pprIfaceDecl ShowSub
_ (IfacePatSyn { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
name,
ifPatUnivBndrs :: IfaceDecl -> [IfaceForAllSpecBndr]
ifPatUnivBndrs = [IfaceForAllSpecBndr]
univ_bndrs, ifPatExBndrs :: IfaceDecl -> [IfaceForAllSpecBndr]
ifPatExBndrs = [IfaceForAllSpecBndr]
ex_bndrs,
ifPatProvCtxt :: IfaceDecl -> IfaceContext
ifPatProvCtxt = IfaceContext
prov_ctxt, ifPatReqCtxt :: IfaceDecl -> IfaceContext
ifPatReqCtxt = IfaceContext
req_ctxt,
ifPatArgs :: IfaceDecl -> IfaceContext
ifPatArgs = IfaceContext
arg_tys, ifFieldLabels :: IfaceDecl -> [FieldLabel]
ifFieldLabels = [FieldLabel]
pat_fldlbls,
ifPatTy :: IfaceDecl -> IfaceType
ifPatTy = IfaceType
pat_ty} )
= (SDocContext -> SDoc) -> SDoc
sdocWithContext SDocContext -> SDoc
mk_msg
where
pat_keywrd :: SDoc
pat_keywrd = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"pattern"
mk_msg :: SDocContext -> SDoc
mk_msg SDocContext
sdocCtx
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc
ppr_pat_ty
, if [FieldLabel] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FieldLabel]
pat_fldlbls then SDoc
forall doc. IsOutput doc => doc
Outputable.empty
else SDoc
pat_keywrd SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IfExtName
name SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pat_body]
where
ppr_pat_ty :: SDoc
ppr_pat_ty =
SDoc -> Int -> SDoc -> SDoc
hang (SDoc
pat_keywrd SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IfExtName
name)
Int
2 (SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc
univ_msg
, IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
req_ctxt
, Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen Bool
insert_empty_ctxt (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens SDoc
forall doc. IsOutput doc => doc
empty SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
darrow
, SDoc
ex_msg
, IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
prov_ctxt
, IfaceType -> SDoc
pprIfaceType (IfaceType -> SDoc) -> IfaceType -> SDoc
forall a b. (a -> b) -> a -> b
$ (IfaceType -> IfaceType -> IfaceType)
-> IfaceType -> IfaceContext -> IfaceType
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (FunTyFlag -> IfaceType -> IfaceType -> IfaceType -> IfaceType
IfaceFunTy FunTyFlag
visArgTypeLike IfaceType
many_ty)
IfaceType
pat_ty IfaceContext
arg_tys ])
pat_body :: SDoc
pat_body = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
comma ([SDoc] -> [SDoc]) -> [SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ (FieldLabel -> SDoc) -> [FieldLabel] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map FieldLabel -> SDoc
forall a. Outputable a => a -> SDoc
ppr [FieldLabel]
pat_fldlbls
univ_msg :: SDoc
univ_msg = [IfaceForAllBndr] -> SDoc
pprUserIfaceForAll ([IfaceForAllBndr] -> SDoc) -> [IfaceForAllBndr] -> SDoc
forall a b. (a -> b) -> a -> b
$ [IfaceForAllSpecBndr] -> [IfaceForAllBndr]
forall a. [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag]
tyVarSpecToBinders [IfaceForAllSpecBndr]
univ_bndrs
ex_msg :: SDoc
ex_msg = [IfaceForAllBndr] -> SDoc
pprUserIfaceForAll ([IfaceForAllBndr] -> SDoc) -> [IfaceForAllBndr] -> SDoc
forall a b. (a -> b) -> a -> b
$ [IfaceForAllSpecBndr] -> [IfaceForAllBndr]
forall a. [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag]
tyVarSpecToBinders [IfaceForAllSpecBndr]
ex_bndrs
insert_empty_ctxt :: Bool
insert_empty_ctxt = IfaceContext -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null IfaceContext
req_ctxt
Bool -> Bool -> Bool
&& Bool -> Bool
not (IfaceContext -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null IfaceContext
prov_ctxt Bool -> Bool -> Bool
&& SDocContext -> SDoc -> Bool
isEmpty SDocContext
sdocCtx SDoc
ex_msg)
pprIfaceDecl ShowSub
ss (IfaceId { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
var, ifType :: IfaceDecl -> IfaceType
ifType = IfaceType
ty,
ifIdDetails :: IfaceDecl -> IfaceIdDetails
ifIdDetails = IfaceIdDetails
details, ifIdInfo :: IfaceDecl -> IfaceIdInfo
ifIdInfo = IfaceIdInfo
info })
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ SDoc -> Int -> SDoc -> SDoc
hang (ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
var) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon)
Int
2 (ShowForAllFlag -> IfaceType -> SDoc
pprIfaceSigmaType (ShowSub -> ShowForAllFlag
ss_forall ShowSub
ss) IfaceType
ty)
, ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (IfaceIdDetails -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceIdDetails
details)
, ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (IfaceIdInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceIdInfo
info) ]
pprIfaceDecl ShowSub
_ (IfaceAxiom { ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
name, ifTyCon :: IfaceDecl -> IfaceTyCon
ifTyCon = IfaceTyCon
tycon
, ifAxBranches :: IfaceDecl -> [IfaceAxBranch]
ifAxBranches = [IfaceAxBranch]
branches })
= SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"axiom" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
name SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon)
Int
2 ([SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ (Int -> IfaceAxBranch -> SDoc) -> [(Int, IfaceAxBranch)] -> [SDoc]
forall a b c. (a -> b -> c) -> [(a, b)] -> [c]
unzipWith (SDoc -> Int -> IfaceAxBranch -> SDoc
pprAxBranch (IfaceTyCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceTyCon
tycon)) ([(Int, IfaceAxBranch)] -> [SDoc])
-> [(Int, IfaceAxBranch)] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ [Int] -> [IfaceAxBranch] -> [(Int, IfaceAxBranch)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0..] [IfaceAxBranch]
branches)
pprCType :: Maybe CType -> SDoc
pprCType :: Maybe CType -> SDoc
pprCType Maybe CType
Nothing = SDoc
forall doc. IsOutput doc => doc
Outputable.empty
pprCType (Just CType
cType) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"C type:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> CType -> SDoc
forall a. Outputable a => a -> SDoc
ppr CType
cType
pprRoles :: (Role -> Bool) -> SDoc -> [IfaceTyConBinder]
-> [Role] -> SDoc
pprRoles :: (Role -> Bool) -> SDoc -> [IfaceTyConBinder] -> [Role] -> SDoc
pprRoles Role -> Bool
suppress_if SDoc
tyCon [IfaceTyConBinder]
bndrs [Role]
roles
= (SDocContext -> Bool) -> (Bool -> SDoc) -> SDoc
forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocPrintExplicitKinds ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \Bool
print_kinds ->
let froles :: [Role]
froles = PrintExplicitKinds -> [IfaceTyConBinder] -> [Role] -> [Role]
forall a. PrintExplicitKinds -> [IfaceTyConBinder] -> [a] -> [a]
suppressIfaceInvisibles (Bool -> PrintExplicitKinds
PrintExplicitKinds Bool
print_kinds) [IfaceTyConBinder]
bndrs [Role]
roles
in Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless ((Role -> Bool) -> [Role] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Role -> Bool
suppress_if [Role]
froles Bool -> Bool -> Bool
|| [Role] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Role]
froles) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type role" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
tyCon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep ((Role -> SDoc) -> [Role] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map Role -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Role]
froles)
pprStandaloneKindSig :: SDoc -> IfaceType -> SDoc
pprStandaloneKindSig :: SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
tyCon IfaceType
ty = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"type" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
tyCon 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
<+> IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
ty
pprInfixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
pprInfixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
pprInfixIfDeclBndr (ShowSome Maybe (OccName -> Bool)
_ (AltPpr (Just OccName -> SDoc
ppr_bndr))) OccName
name
= Bool -> SDoc -> SDoc
pprInfixVar (OccName -> Bool
isSymOcc OccName
name) (OccName -> SDoc
ppr_bndr OccName
name)
pprInfixIfDeclBndr ShowHowMuch
_ OccName
name
= Bool -> SDoc -> SDoc
pprInfixVar (OccName -> Bool
isSymOcc OccName
name) (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
name)
pprPrefixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowHeader (AltPpr (Just OccName -> SDoc
ppr_bndr))) OccName
name
= OccName -> SDoc -> SDoc
parenSymOcc OccName
name (OccName -> SDoc
ppr_bndr OccName
name)
pprPrefixIfDeclBndr (ShowSome Maybe (OccName -> Bool)
_ (AltPpr (Just OccName -> SDoc
ppr_bndr))) OccName
name
= OccName -> SDoc -> SDoc
parenSymOcc OccName
name (OccName -> SDoc
ppr_bndr OccName
name)
pprPrefixIfDeclBndr ShowHowMuch
_ OccName
name
= OccName -> SDoc -> SDoc
parenSymOcc OccName
name (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
name)
instance Outputable IfaceClassOp where
ppr :: IfaceClassOp -> SDoc
ppr = ShowSub -> IfaceClassOp -> SDoc
pprIfaceClassOp ShowSub
showToIface
pprIfaceClassOp :: ShowSub -> IfaceClassOp -> SDoc
pprIfaceClassOp :: ShowSub -> IfaceClassOp -> SDoc
pprIfaceClassOp ShowSub
ss (IfaceClassOp IfExtName
n IfaceType
ty Maybe (DefMethSpec IfaceType)
dm)
= IfExtName -> IfaceType -> SDoc
pp_sig IfExtName
n IfaceType
ty SDoc -> SDoc -> SDoc
forall doc. IsDoc doc => doc -> doc -> doc
$$ SDoc
generic_dm
where
generic_dm :: SDoc
generic_dm | Just (GenericDM IfaceType
dm_ty) <- Maybe (DefMethSpec IfaceType)
dm
= String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"default" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> IfaceType -> SDoc
pp_sig IfExtName
n IfaceType
dm_ty
| Bool
otherwise
= SDoc
forall doc. IsOutput doc => doc
empty
pp_sig :: IfExtName -> IfaceType -> SDoc
pp_sig IfExtName
n IfaceType
ty
= ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
n)
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> ShowForAllFlag -> IfaceType -> SDoc
pprIfaceSigmaType ShowForAllFlag
ShowForAllWhen IfaceType
ty
instance Outputable IfaceAT where
ppr :: IfaceAT -> SDoc
ppr = ShowSub -> IfaceAT -> SDoc
pprIfaceAT ShowSub
showToIface
pprIfaceAT :: ShowSub -> IfaceAT -> SDoc
pprIfaceAT :: ShowSub -> IfaceAT -> SDoc
pprIfaceAT ShowSub
ss (IfaceAT IfaceDecl
d Maybe IfaceType
mb_def)
= [SDoc] -> SDoc
forall doc. IsDoc doc => [doc] -> doc
vcat [ ShowSub -> IfaceDecl -> SDoc
pprIfaceDecl ShowSub
ss IfaceDecl
d
, case Maybe IfaceType
mb_def of
Maybe IfaceType
Nothing -> SDoc
forall doc. IsOutput doc => doc
Outputable.empty
Just IfaceType
rhs -> Int -> SDoc -> SDoc
nest Int
2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Default:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
rhs ]
instance Outputable IfaceTyConParent where
ppr :: IfaceTyConParent -> SDoc
ppr IfaceTyConParent
p = IfaceTyConParent -> SDoc
pprIfaceTyConParent IfaceTyConParent
p
pprIfaceTyConParent :: IfaceTyConParent -> SDoc
pprIfaceTyConParent :: IfaceTyConParent -> SDoc
pprIfaceTyConParent IfaceTyConParent
IfNoParent
= SDoc
forall doc. IsOutput doc => doc
Outputable.empty
pprIfaceTyConParent (IfDataInstance IfExtName
_ IfaceTyCon
tc IfaceAppArgs
tys)
= PprPrec -> IfaceTyCon -> IfaceAppArgs -> SDoc
pprIfaceTypeApp PprPrec
topPrec IfaceTyCon
tc IfaceAppArgs
tys
pprIfaceDeclHead :: SuppressBndrSig
-> IfaceContext -> ShowSub -> Name
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead :: SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_sig IfaceContext
context ShowSub
ss IfExtName
tc_occ [IfaceTyConBinder]
bndrs
= (SDocContext -> Bool) -> (Bool -> SDoc) -> SDoc
forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocPrintExplicitKinds ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \Bool
print_kinds ->
[SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
context
, ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
tc_occ)
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SuppressBndrSig -> [IfaceTyConBinder] -> SDoc
pprIfaceTyConBinders SuppressBndrSig
suppress_sig
(PrintExplicitKinds
-> [IfaceTyConBinder] -> [IfaceTyConBinder] -> [IfaceTyConBinder]
forall a. PrintExplicitKinds -> [IfaceTyConBinder] -> [a] -> [a]
suppressIfaceInvisibles (Bool -> PrintExplicitKinds
PrintExplicitKinds Bool
print_kinds) [IfaceTyConBinder]
bndrs [IfaceTyConBinder]
bndrs) ]
pprIfaceConDecl :: ShowSub -> Bool
-> IfaceTopBndr
-> [IfaceTyConBinder]
-> IfaceTyConParent
-> IfaceConDecl -> SDoc
pprIfaceConDecl :: ShowSub
-> Bool
-> IfExtName
-> [IfaceTyConBinder]
-> IfaceTyConParent
-> IfaceConDecl
-> SDoc
pprIfaceConDecl ShowSub
ss Bool
gadt_style IfExtName
tycon [IfaceTyConBinder]
tc_binders IfaceTyConParent
parent
(IfCon { ifConName :: IfaceConDecl -> IfExtName
ifConName = IfExtName
name, ifConInfix :: IfaceConDecl -> Bool
ifConInfix = Bool
is_infix,
ifConUserTvBinders :: IfaceConDecl -> [IfaceForAllSpecBndr]
ifConUserTvBinders = [IfaceForAllSpecBndr]
user_tvbs,
ifConEqSpec :: IfaceConDecl -> [IfaceTvBndr]
ifConEqSpec = [IfaceTvBndr]
eq_spec, ifConCtxt :: IfaceConDecl -> IfaceContext
ifConCtxt = IfaceContext
ctxt, ifConArgTys :: IfaceConDecl -> [(IfaceType, IfaceType)]
ifConArgTys = [(IfaceType, IfaceType)]
arg_tys,
ifConStricts :: IfaceConDecl -> [IfaceBang]
ifConStricts = [IfaceBang]
stricts, ifConFields :: IfaceConDecl -> [FieldLabel]
ifConFields = [FieldLabel]
fields })
| Bool
gadt_style = SDoc
pp_prefix_con SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
ppr_gadt_ty
| Bool
otherwise = SDoc -> SDoc
ppr_ex_quant SDoc
pp_h98_con
where
pp_h98_con :: SDoc
pp_h98_con
| Bool -> Bool
not ([FieldLabel] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FieldLabel]
fields) = SDoc
pp_prefix_con SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_field_args
| Bool
is_infix
, [SDoc
ty1, SDoc
ty2] <- [SDoc]
pp_args
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ SDoc
ty1
, ShowHowMuch -> OccName -> SDoc
pprInfixIfDeclBndr ShowHowMuch
how_much (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
name)
, SDoc
ty2]
| Bool
otherwise = SDoc
pp_prefix_con SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc]
pp_args
how_much :: ShowHowMuch
how_much = ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss
tys_w_strs :: [(IfaceBang, IfaceType)]
tys_w_strs :: [(IfaceBang, IfaceType)]
tys_w_strs = [IfaceBang] -> IfaceContext -> [(IfaceBang, IfaceType)]
forall a b. [a] -> [b] -> [(a, b)]
zip [IfaceBang]
stricts (((IfaceType, IfaceType) -> IfaceType)
-> [(IfaceType, IfaceType)] -> IfaceContext
forall a b. (a -> b) -> [a] -> [b]
map (IfaceType, IfaceType) -> IfaceType
forall a b. (a, b) -> b
snd [(IfaceType, IfaceType)]
arg_tys)
pp_prefix_con :: SDoc
pp_prefix_con = ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr ShowHowMuch
how_much (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
name)
ex_tvbs :: [IfaceForAllSpecBndr]
ex_tvbs = [IfaceTyConBinder]
-> [IfaceForAllSpecBndr] -> [IfaceForAllSpecBndr]
forall b a. [b] -> [a] -> [a]
dropList [IfaceTyConBinder]
tc_binders [IfaceForAllSpecBndr]
user_tvbs
ppr_ex_quant :: SDoc -> SDoc
ppr_ex_quant = [IfaceForAllBndr] -> IfaceContext -> SDoc -> SDoc
pprIfaceForAllPartMust ([IfaceForAllSpecBndr] -> [IfaceForAllBndr]
ifaceForAllSpecToBndrs [IfaceForAllSpecBndr]
ex_tvbs) IfaceContext
ctxt
pp_gadt_res_ty :: SDoc
pp_gadt_res_ty = [IfaceTvBndr] -> SDoc
mk_user_con_res_ty [IfaceTvBndr]
eq_spec
ppr_gadt_ty :: SDoc
ppr_gadt_ty = [IfaceForAllBndr] -> IfaceContext -> SDoc -> SDoc
pprIfaceForAllPart ([IfaceForAllSpecBndr] -> [IfaceForAllBndr]
ifaceForAllSpecToBndrs [IfaceForAllSpecBndr]
user_tvbs) IfaceContext
ctxt SDoc
pp_tau
pp_tau :: SDoc
pp_tau | [FieldLabel] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FieldLabel]
fields
= case [SDoc]
pp_args [SDoc] -> [SDoc] -> [SDoc]
forall a. [a] -> [a] -> [a]
++ [SDoc
pp_gadt_res_ty] of
(SDoc
t:[SDoc]
ts) -> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
fsep (SDoc
t SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: String
-> ((IfaceType, IfaceType) -> SDoc -> SDoc)
-> [(IfaceType, IfaceType)]
-> [SDoc]
-> [SDoc]
forall a b c.
HasDebugCallStack =>
String -> (a -> b -> c) -> [a] -> [b] -> [c]
zipWithEqual String
"pprIfaceConDecl" (\(IfaceType
w,IfaceType
_) SDoc
d -> IfaceType -> SDoc
ppr_arr IfaceType
w SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
d)
[(IfaceType, IfaceType)]
arg_tys [SDoc]
ts)
[] -> String -> SDoc
forall a. HasCallStack => String -> a
panic String
"pp_con_taus"
| Bool
otherwise
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc
pp_field_args, SDoc
arrow SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
pp_gadt_res_ty]
ppr_arr :: IfaceType -> SDoc
ppr_arr IfaceType
w = (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
linearTypes ->
if Bool
linearTypes
then FunTyFlag -> IfaceType -> SDoc
pprTypeArrow FunTyFlag
visArgTypeLike IfaceType
w
else SDoc
arrow
ppr_bang :: IfaceBang -> SDoc
ppr_bang IfaceBang
IfNoBang = SDoc -> SDoc
forall doc. IsOutput doc => doc -> doc
whenPprDebug (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'_'
ppr_bang IfaceBang
IfStrict = Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'!'
ppr_bang IfaceBang
IfUnpack = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"{-# UNPACK #-}"
ppr_bang (IfUnpackCo IfaceCoercion
co) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"! {-# UNPACK #-}" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<>
IfaceCoercion -> SDoc
pprParendIfaceCoercion IfaceCoercion
co
pprFieldArgTy, pprArgTy :: (IfaceBang, IfaceType) -> SDoc
pprFieldArgTy :: (IfaceBang, IfaceType) -> SDoc
pprFieldArgTy (IfaceBang
bang, IfaceType
ty) = PprPrec -> IfaceBang -> IfaceType -> SDoc
ppr_arg_ty (IfaceBang -> PprPrec
bang_prec IfaceBang
bang) IfaceBang
bang IfaceType
ty
pprArgTy :: (IfaceBang, IfaceType) -> SDoc
pprArgTy (IfaceBang
bang, IfaceType
ty) = PprPrec -> IfaceBang -> IfaceType -> SDoc
ppr_arg_ty (PprPrec -> PprPrec -> PprPrec
forall a. Ord a => a -> a -> a
max PprPrec
gadt_prec (IfaceBang -> PprPrec
bang_prec IfaceBang
bang)) IfaceBang
bang IfaceType
ty
ppr_arg_ty :: PprPrec -> IfaceBang -> IfaceType -> SDoc
ppr_arg_ty :: PprPrec -> IfaceBang -> IfaceType -> SDoc
ppr_arg_ty PprPrec
prec IfaceBang
bang IfaceType
ty = IfaceBang -> SDoc
ppr_bang IfaceBang
bang SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> PprPrec -> IfaceType -> SDoc
pprPrecIfaceType PprPrec
prec IfaceType
ty
gadt_prec :: PprPrec
gadt_prec :: PprPrec
gadt_prec
| Bool
gadt_style = PprPrec
funPrec
| Bool
otherwise = PprPrec
appPrec
bang_prec :: IfaceBang -> PprPrec
bang_prec :: IfaceBang -> PprPrec
bang_prec IfaceBang
IfNoBang = PprPrec
topPrec
bang_prec IfaceBang
IfStrict = PprPrec
appPrec
bang_prec IfaceBang
IfUnpack = PprPrec
appPrec
bang_prec IfUnpackCo{} = PprPrec
appPrec
pp_args :: [SDoc]
pp_args :: [SDoc]
pp_args = ((IfaceBang, IfaceType) -> SDoc)
-> [(IfaceBang, IfaceType)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (IfaceBang, IfaceType) -> SDoc
pprArgTy [(IfaceBang, IfaceType)]
tys_w_strs
pp_field_args :: SDoc
pp_field_args :: SDoc
pp_field_args = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> [SDoc] -> [SDoc]
forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate SDoc
forall doc. IsLine doc => doc
comma ([SDoc] -> [SDoc]) -> [SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ [Maybe SDoc] -> [SDoc]
ppr_trim ([Maybe SDoc] -> [SDoc]) -> [Maybe SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$
(FieldLabel -> (IfaceBang, IfaceType) -> Maybe SDoc)
-> [FieldLabel] -> [(IfaceBang, IfaceType)] -> [Maybe SDoc]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith FieldLabel -> (IfaceBang, IfaceType) -> Maybe SDoc
maybe_show_label [FieldLabel]
fields [(IfaceBang, IfaceType)]
tys_w_strs
maybe_show_label :: FieldLabel -> (IfaceBang, IfaceType) -> Maybe SDoc
maybe_show_label :: FieldLabel -> (IfaceBang, IfaceType) -> Maybe SDoc
maybe_show_label FieldLabel
lbl (IfaceBang, IfaceType)
bty
| ShowSub -> IfExtName -> Bool
forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfExtName
sel = SDoc -> Maybe SDoc
forall a. a -> Maybe a
Just (ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr ShowHowMuch
how_much OccName
occ
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (IfaceBang, IfaceType) -> SDoc
pprFieldArgTy (IfaceBang, IfaceType)
bty)
| Bool
otherwise = Maybe SDoc
forall a. Maybe a
Nothing
where
sel :: IfExtName
sel = FieldLabel -> IfExtName
flSelector FieldLabel
lbl
occ :: OccName
occ = IfExtName -> OccName
nameOccName IfExtName
sel
mk_user_con_res_ty :: IfaceEqSpec -> SDoc
mk_user_con_res_ty :: [IfaceTvBndr] -> SDoc
mk_user_con_res_ty [IfaceTvBndr]
eq_spec
| IfDataInstance IfExtName
_ IfaceTyCon
tc IfaceAppArgs
tys <- IfaceTyConParent
parent
= IfaceType -> SDoc
pprIfaceType (IfaceTyCon -> IfaceAppArgs -> IfaceType
IfaceTyConApp IfaceTyCon
tc (IfaceTySubst -> IfaceAppArgs -> IfaceAppArgs
substIfaceAppArgs IfaceTySubst
gadt_subst IfaceAppArgs
tys))
| Bool
otherwise
= IfaceTySubst -> SDoc
ppr_tc_app IfaceTySubst
gadt_subst
where
gadt_subst :: IfaceTySubst
gadt_subst = [IfaceTvBndr] -> IfaceTySubst
mkIfaceTySubst [IfaceTvBndr]
eq_spec
ppr_tc_app :: IfaceTySubst -> SDoc
ppr_tc_app IfaceTySubst
gadt_subst =
ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr ShowHowMuch
how_much (IfExtName -> OccName
forall name. HasOccName name => name -> OccName
occName IfExtName
tycon)
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceAppArgs -> SDoc
pprParendIfaceAppArgs
(IfaceTySubst -> IfaceAppArgs -> IfaceAppArgs
substIfaceAppArgs IfaceTySubst
gadt_subst ([IfaceTyConBinder] -> IfaceAppArgs
mk_tc_app_args [IfaceTyConBinder]
tc_binders))
mk_tc_app_args :: [IfaceTyConBinder] -> IfaceAppArgs
mk_tc_app_args :: [IfaceTyConBinder] -> IfaceAppArgs
mk_tc_app_args [] = IfaceAppArgs
IA_Nil
mk_tc_app_args (Bndr IfaceBndr
bndr TyConBndrVis
vis:[IfaceTyConBinder]
tc_bndrs) =
IfaceType -> ForAllTyFlag -> IfaceAppArgs -> IfaceAppArgs
IA_Arg (IfLclName -> IfaceType
IfaceTyVar (IfaceBndr -> IfLclName
ifaceBndrName IfaceBndr
bndr)) (TyConBndrVis -> ForAllTyFlag
tyConBndrVisForAllTyFlag TyConBndrVis
vis)
([IfaceTyConBinder] -> IfaceAppArgs
mk_tc_app_args [IfaceTyConBinder]
tc_bndrs)
instance Outputable IfaceRule where
ppr :: IfaceRule -> SDoc
ppr (IfaceRule { ifRuleName :: IfaceRule -> FastString
ifRuleName = FastString
name, ifActivation :: IfaceRule -> Activation
ifActivation = Activation
act, ifRuleBndrs :: IfaceRule -> [IfaceBndr]
ifRuleBndrs = [IfaceBndr]
bndrs,
ifRuleHead :: IfaceRule -> IfExtName
ifRuleHead = IfExtName
fn, ifRuleArgs :: IfaceRule -> [IfaceExpr]
ifRuleArgs = [IfaceExpr]
args, ifRuleRhs :: IfaceRule -> IfaceExpr
ifRuleRhs = IfaceExpr
rhs,
ifRuleOrph :: IfaceRule -> IsOrphan
ifRuleOrph = IsOrphan
orph })
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep [ FastString -> SDoc
pprRuleName FastString
name
, if IsOrphan -> Bool
isOrphan IsOrphan
orph then String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[orphan]" else SDoc
forall doc. IsOutput doc => doc
Outputable.empty
, Activation -> SDoc
forall a. Outputable a => a -> SDoc
ppr Activation
act
, SDoc
pp_foralls ]
, Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
fn SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ((IfaceExpr -> SDoc) -> [IfaceExpr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceExpr -> SDoc
pprParendIfaceExpr [IfaceExpr]
args),
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"=" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceExpr -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceExpr
rhs]) ]
where
pp_foralls :: SDoc
pp_foralls = Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppUnless ([IfaceBndr] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceBndr]
bndrs) (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc
forAllLit SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [IfaceBndr] -> SDoc
pprIfaceBndrs [IfaceBndr]
bndrs SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
dot
instance Outputable IfaceDefault where
ppr :: IfaceDefault -> SDoc
ppr (IfaceDefault { ifDefaultCls :: IfaceDefault -> IfaceTyCon
ifDefaultCls = IfaceTyCon
cls, ifDefaultTys :: IfaceDefault -> IfaceContext
ifDefaultTys = IfaceContext
tcs })
= String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"default" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceTyCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceTyCon
cls SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens ((IfaceType -> SDoc) -> IfaceContext -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceContext
tcs)
instance Outputable IfaceClsInst where
ppr :: IfaceClsInst -> SDoc
ppr (IfaceClsInst { ifDFun :: IfaceClsInst -> IfExtName
ifDFun = IfExtName
dfun_id, ifOFlag :: IfaceClsInst -> OverlapFlag
ifOFlag = OverlapFlag
flag
, ifInstCls :: IfaceClsInst -> IfExtName
ifInstCls = IfExtName
cls, ifInstTys :: IfaceClsInst -> [Maybe IfaceTyCon]
ifInstTys = [Maybe IfaceTyCon]
mb_tcs
, ifInstOrph :: IfaceClsInst -> IsOrphan
ifInstOrph = IsOrphan
orph })
= SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"instance" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> OverlapFlag -> SDoc
forall a. Outputable a => a -> SDoc
ppr OverlapFlag
flag
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (if IsOrphan -> Bool
isOrphan IsOrphan
orph then String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[orphan]" else SDoc
forall doc. IsOutput doc => doc
Outputable.empty)
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
cls SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets ((Maybe IfaceTyCon -> SDoc) -> [Maybe IfaceTyCon] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas Maybe IfaceTyCon -> SDoc
ppr_rough [Maybe IfaceTyCon]
mb_tcs))
Int
2 (SDoc
forall doc. IsLine doc => doc
equals SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
dfun_id)
instance Outputable IfaceFamInst where
ppr :: IfaceFamInst -> SDoc
ppr (IfaceFamInst { ifFamInstFam :: IfaceFamInst -> IfExtName
ifFamInstFam = IfExtName
fam, ifFamInstTys :: IfaceFamInst -> [Maybe IfaceTyCon]
ifFamInstTys = [Maybe IfaceTyCon]
mb_tcs
, ifFamInstAxiom :: IfaceFamInst -> IfExtName
ifFamInstAxiom = IfExtName
tycon_ax, ifFamInstOrph :: IfaceFamInst -> IsOrphan
ifFamInstOrph = IsOrphan
orph })
= SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"family instance"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (if IsOrphan -> Bool
isOrphan IsOrphan
orph then String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[orphan]" else SDoc
forall doc. IsOutput doc => doc
Outputable.empty)
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
fam SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (Maybe IfaceTyCon -> SDoc) -> [Maybe IfaceTyCon] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets (SDoc -> SDoc)
-> (Maybe IfaceTyCon -> SDoc) -> Maybe IfaceTyCon -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe IfaceTyCon -> SDoc
ppr_rough) [Maybe IfaceTyCon]
mb_tcs)
Int
2 (SDoc
forall doc. IsLine doc => doc
equals SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
tycon_ax)
ppr_rough :: Maybe IfaceTyCon -> SDoc
ppr_rough :: Maybe IfaceTyCon -> SDoc
ppr_rough Maybe IfaceTyCon
Nothing = SDoc
forall doc. IsLine doc => doc
dot
ppr_rough (Just IfaceTyCon
tc) = IfaceTyCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceTyCon
tc
instance Outputable IfaceExpr where
ppr :: IfaceExpr -> SDoc
ppr IfaceExpr
e = (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
e
noParens :: SDoc -> SDoc
noParens :: SDoc -> SDoc
noParens SDoc
pp = SDoc
pp
pprParendIfaceExpr :: IfaceExpr -> SDoc
pprParendIfaceExpr :: IfaceExpr -> SDoc
pprParendIfaceExpr = (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens
pprIfaceExpr :: (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr :: (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
_ (IfaceLcl IfLclName
v) = IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
v
pprIfaceExpr SDoc -> SDoc
_ (IfaceExt IfExtName
v) = IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
v
pprIfaceExpr SDoc -> SDoc
_ (IfaceLit Literal
l) = Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
l
pprIfaceExpr SDoc -> SDoc
_ (IfaceFCall ForeignCall
cc IfaceType
ty) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (ForeignCall -> SDoc
forall a. Outputable a => a -> SDoc
ppr ForeignCall
cc SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
ty)
pprIfaceExpr SDoc -> SDoc
_ (IfaceType IfaceType
ty) = Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'@' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> IfaceType -> SDoc
pprParendIfaceType IfaceType
ty
pprIfaceExpr SDoc -> SDoc
_ (IfaceCo IfaceCoercion
co) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"@~" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> IfaceCoercion -> SDoc
pprParendIfaceCoercion IfaceCoercion
co
pprIfaceExpr SDoc -> SDoc
_ (IfaceTuple TupleSort
c [IfaceExpr]
as) = TupleSort -> SDoc -> SDoc
tupleParens TupleSort
c ((IfaceExpr -> SDoc) -> [IfaceExpr] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas IfaceExpr -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IfaceExpr]
as)
pprIfaceExpr SDoc -> SDoc
_ (IfaceLitRubbish TypeOrConstraint
tc IfaceType
r)
= String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"RUBBISH"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> (case TypeOrConstraint
tc of { TypeOrConstraint
TypeLike -> SDoc
forall doc. IsOutput doc => doc
empty; TypeOrConstraint
ConstraintLike -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[c]" })
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
r)
pprIfaceExpr SDoc -> SDoc
add_par app :: IfaceExpr
app@(IfaceApp IfaceExpr
_ IfaceExpr
_) = SDoc -> SDoc
add_par (IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp IfaceExpr
app [])
pprIfaceExpr SDoc -> SDoc
add_par i :: IfaceExpr
i@(IfaceLam IfaceLamBndr
_ IfaceExpr
_)
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'\\' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ((IfaceLamBndr -> SDoc) -> [IfaceLamBndr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceLamBndr -> SDoc
pprIfaceLamBndr [IfaceLamBndr]
bndrs) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
arrow,
(SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
body])
where
([IfaceLamBndr]
bndrs,IfaceExpr
body) = [IfaceLamBndr] -> IfaceExpr -> ([IfaceLamBndr], IfaceExpr)
collect [] IfaceExpr
i
collect :: [IfaceLamBndr] -> IfaceExpr -> ([IfaceLamBndr], IfaceExpr)
collect [IfaceLamBndr]
bs (IfaceLam IfaceLamBndr
b IfaceExpr
e) = [IfaceLamBndr] -> IfaceExpr -> ([IfaceLamBndr], IfaceExpr)
collect (IfaceLamBndr
bIfaceLamBndr -> [IfaceLamBndr] -> [IfaceLamBndr]
forall a. a -> [a] -> [a]
:[IfaceLamBndr]
bs) IfaceExpr
e
collect [IfaceLamBndr]
bs IfaceExpr
e = ([IfaceLamBndr] -> [IfaceLamBndr]
forall a. [a] -> [a]
reverse [IfaceLamBndr]
bs, IfaceExpr
e)
pprIfaceExpr SDoc -> SDoc
add_par (IfaceECase IfaceExpr
scrut IfaceType
ty)
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
scrut
, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ret_ty" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceType -> SDoc
pprParendIfaceType IfaceType
ty
, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"of {}" ])
pprIfaceExpr SDoc -> SDoc
add_par (IfaceCase IfaceExpr
scrut IfLclName
bndr [IfaceAlt IfaceConAlt
con [IfLclName]
bs IfaceExpr
rhs])
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
scrut SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"of"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
bndr 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
<+> IfaceConAlt -> [IfLclName] -> SDoc
ppr_con_bs IfaceConAlt
con [IfLclName]
bs SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
arrow,
(SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
rhs SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'}'])
pprIfaceExpr SDoc -> SDoc
add_par (IfaceCase IfaceExpr
scrut IfLclName
bndr [IfaceAlt]
alts)
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"case"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
scrut SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"of"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
bndr SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'{',
Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ((IfaceAlt -> SDoc) -> [IfaceAlt] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceAlt -> SDoc
pprIfaceAlt [IfaceAlt]
alts)) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'}'])
pprIfaceExpr SDoc -> SDoc
_ (IfaceCast IfaceExpr
expr IfaceCoercion
co)
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [IfaceExpr -> SDoc
pprParendIfaceExpr IfaceExpr
expr,
Int -> SDoc -> SDoc
nest Int
2 (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"`cast`"),
IfaceCoercion -> SDoc
pprParendIfaceCoercion IfaceCoercion
co]
pprIfaceExpr SDoc -> SDoc
add_par (IfaceLet (IfaceNonRec IfaceLetBndr
b IfaceExpr
rhs) IfaceExpr
body)
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"let {",
Int -> SDoc -> SDoc
nest Int
2 ((IfaceLetBndr, IfaceExpr) -> SDoc
ppr_bind (IfaceLetBndr
b, IfaceExpr
rhs)),
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"} in",
(SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
body])
pprIfaceExpr SDoc -> SDoc
add_par (IfaceLet (IfaceRec [(IfaceLetBndr, IfaceExpr)]
pairs) IfaceExpr
body)
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"letrec {",
Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep (((IfaceLetBndr, IfaceExpr) -> SDoc)
-> [(IfaceLetBndr, IfaceExpr)] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (IfaceLetBndr, IfaceExpr) -> SDoc
ppr_bind [(IfaceLetBndr, IfaceExpr)]
pairs)),
String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"} in",
(SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
body])
pprIfaceExpr SDoc -> SDoc
add_par (IfaceTick IfaceTickish
tickish IfaceExpr
e)
= SDoc -> SDoc
add_par (IfaceTickish -> SDoc
pprIfaceTickish IfaceTickish
tickish SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
e)
pprIfaceAlt :: IfaceAlt -> SDoc
pprIfaceAlt :: IfaceAlt -> SDoc
pprIfaceAlt (IfaceAlt IfaceConAlt
con [IfLclName]
bs IfaceExpr
rhs)
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [IfaceConAlt -> [IfLclName] -> SDoc
ppr_con_bs IfaceConAlt
con [IfLclName]
bs, SDoc
arrow SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
rhs]
ppr_con_bs :: IfaceConAlt -> [IfLclName] -> SDoc
ppr_con_bs :: IfaceConAlt -> [IfLclName] -> SDoc
ppr_con_bs IfaceConAlt
con [IfLclName]
bs = IfaceConAlt -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceConAlt
con SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
hsep ((IfLclName -> SDoc) -> [IfLclName] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IfLclName]
bs)
ppr_bind :: (IfaceLetBndr, IfaceExpr) -> SDoc
ppr_bind :: (IfaceLetBndr, IfaceExpr) -> SDoc
ppr_bind (IfLetBndr IfLclName
b IfaceType
ty IfaceIdInfo
info JoinPointHood
ji, IfaceExpr
rhs)
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [SDoc -> Int -> SDoc -> SDoc
hang (IfLclName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfLclName
b SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceType -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceType
ty) Int
2 (JoinPointHood -> SDoc
forall a. Outputable a => a -> SDoc
ppr JoinPointHood
ji SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceIdInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceIdInfo
info),
SDoc
forall doc. IsLine doc => doc
equals SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
rhs]
pprIfaceTickish :: IfaceTickish -> SDoc
pprIfaceTickish :: IfaceTickish -> SDoc
pprIfaceTickish (IfaceHpcTick Module
m Int
ix)
= SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"tick" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
m SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
ix)
pprIfaceTickish (IfaceSCC CostCentre
cc Bool
tick Bool
scope)
= SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (CostCentre -> SDoc
pprCostCentreCore CostCentre
cc SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
tick SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
scope)
pprIfaceTickish (IfaceSource RealSrcSpan
src FastString
_names)
= SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (Bool -> RealSrcSpan -> SDoc
pprUserRealSpan Bool
True RealSrcSpan
src)
pprIfaceTickish (IfaceBreakpoint Int
m [IfaceExpr]
ix Module
fvs)
= SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"break" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
m SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [IfaceExpr] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IfaceExpr]
ix SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
fvs)
pprIfaceApp :: IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp :: IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp (IfaceApp IfaceExpr
fun IfaceExpr
arg) [SDoc]
args = IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp IfaceExpr
fun ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$
Int -> SDoc -> SDoc
nest Int
2 (IfaceExpr -> SDoc
pprParendIfaceExpr IfaceExpr
arg) SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: [SDoc]
args
pprIfaceApp IfaceExpr
fun [SDoc]
args = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep (IfaceExpr -> SDoc
pprParendIfaceExpr IfaceExpr
fun SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: [SDoc]
args)
instance Outputable IfaceConAlt where
ppr :: IfaceConAlt -> SDoc
ppr IfaceConAlt
IfaceDefaultAlt = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"DEFAULT"
ppr (IfaceLitAlt Literal
l) = Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
l
ppr (IfaceDataAlt IfExtName
d) = IfExtName -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfExtName
d
instance Outputable IfaceIdDetails where
ppr :: IfaceIdDetails -> SDoc
ppr IfaceIdDetails
IfVanillaId = SDoc
forall doc. IsOutput doc => doc
Outputable.empty
ppr (IfWorkerLikeId [CbvMark]
dmd) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"StrWork" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens ([CbvMark] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [CbvMark]
dmd)
ppr (IfRecSelId Either IfaceTyCon IfaceDecl
tc IfExtName
_c Bool
b FieldLabel
_fl) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"RecSel" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Either IfaceTyCon IfaceDecl -> SDoc
forall a. Outputable a => a -> SDoc
ppr Either IfaceTyCon IfaceDecl
tc
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> if Bool
b
then String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"<naughty>"
else SDoc
forall doc. IsOutput doc => doc
Outputable.empty
ppr IfaceIdDetails
IfDFunId = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"DFunId"
instance Outputable IfaceInfoItem where
ppr :: IfaceInfoItem -> SDoc
ppr (HsUnfold Bool
lb IfaceUnfolding
unf) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Unfolding"
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Bool -> SDoc -> SDoc
forall doc. IsOutput doc => Bool -> doc -> doc
ppWhen Bool
lb (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"(loop-breaker)")
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceUnfolding -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceUnfolding
unf
ppr (HsInline InlinePragma
prag) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Inline:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> InlinePragma -> SDoc
forall a. Outputable a => a -> SDoc
ppr InlinePragma
prag
ppr (HsArity Int
arity) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Arity:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Int -> SDoc
forall doc. IsLine doc => Int -> doc
int Int
arity
ppr (HsDmdSig DmdSig
str) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Strictness:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> DmdSig -> SDoc
forall a. Outputable a => a -> SDoc
ppr DmdSig
str
ppr (HsCprSig CprSig
cpr) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"CPR:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> CprSig -> SDoc
forall a. Outputable a => a -> SDoc
ppr CprSig
cpr
ppr IfaceInfoItem
HsNoCafRefs = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"HasNoCafRefs"
ppr (HsLFInfo IfaceLFInfo
lf_info) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"LambdaFormInfo:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfaceLFInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceLFInfo
lf_info
ppr (HsTagSig TagSig
tag_sig) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"TagSig:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> TagSig -> SDoc
forall a. Outputable a => a -> SDoc
ppr TagSig
tag_sig
instance Outputable IfaceUnfolding where
ppr :: IfaceUnfolding -> SDoc
ppr (IfCoreUnfold UnfoldingSource
src IfUnfoldingCache
_ IfGuidance
guide IfaceExpr
e)
= [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [ String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Core:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> UnfoldingSource -> SDoc
forall a. Outputable a => a -> SDoc
ppr UnfoldingSource
src SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> IfGuidance -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfGuidance
guide, IfaceExpr -> SDoc
forall a. Outputable a => a -> SDoc
ppr IfaceExpr
e ]
ppr (IfDFunUnfold [IfaceBndr]
bs [IfaceExpr]
es) = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"DFun:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ((IfaceBndr -> SDoc) -> [IfaceBndr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceBndr -> SDoc
forall a. Outputable a => a -> SDoc
ppr [IfaceBndr]
bs) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
dot)
Int
2 ([SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep ((IfaceExpr -> SDoc) -> [IfaceExpr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map IfaceExpr -> SDoc
pprParendIfaceExpr [IfaceExpr]
es))
instance Outputable IfGuidance where
ppr :: IfGuidance -> SDoc
ppr IfGuidance
IfNoGuidance = SDoc
forall doc. IsOutput doc => doc
empty
ppr (IfWhen Int
a Bool
u Bool
b) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
angleBrackets (Int -> SDoc
forall a. Outputable a => a -> SDoc
ppr Int
a SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
comma SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
u SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
b)
freeNamesIfDecl :: IfaceDecl -> NameSet
freeNamesIfDecl :: IfaceDecl -> NameSet
freeNamesIfDecl (IfaceId { ifType :: IfaceDecl -> IfaceType
ifType = IfaceType
t, ifIdDetails :: IfaceDecl -> IfaceIdDetails
ifIdDetails = IfaceIdDetails
d, ifIdInfo :: IfaceDecl -> IfaceIdInfo
ifIdInfo = IfaceIdInfo
i})
= IfaceType -> NameSet
freeNamesIfType IfaceType
t NameSet -> NameSet -> NameSet
&&&
IfaceIdInfo -> NameSet
freeNamesIfIdInfo IfaceIdInfo
i NameSet -> NameSet -> NameSet
&&&
IfaceIdDetails -> NameSet
freeNamesIfIdDetails IfaceIdDetails
d
freeNamesIfDecl (IfaceData { ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
bndrs, ifResKind :: IfaceDecl -> IfaceType
ifResKind = IfaceType
res_k
, ifParent :: IfaceDecl -> IfaceTyConParent
ifParent = IfaceTyConParent
p, ifCtxt :: IfaceDecl -> IfaceContext
ifCtxt = IfaceContext
ctxt, ifCons :: IfaceDecl -> IfaceConDecls
ifCons = IfaceConDecls
cons })
= [IfaceTyConBinder] -> NameSet
forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs [IfaceTyConBinder]
bndrs NameSet -> NameSet -> NameSet
&&&
IfaceType -> NameSet
freeNamesIfType IfaceType
res_k NameSet -> NameSet -> NameSet
&&&
IfaceTyConParent -> NameSet
freeNamesIfaceTyConParent IfaceTyConParent
p NameSet -> NameSet -> NameSet
&&&
IfaceContext -> NameSet
freeNamesIfContext IfaceContext
ctxt NameSet -> NameSet -> NameSet
&&&
IfaceConDecls -> NameSet
freeNamesIfConDecls IfaceConDecls
cons
freeNamesIfDecl (IfaceSynonym { ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
bndrs, ifResKind :: IfaceDecl -> IfaceType
ifResKind = IfaceType
res_k
, ifSynRhs :: IfaceDecl -> IfaceType
ifSynRhs = IfaceType
rhs })
= [IfaceTyConBinder] -> NameSet
forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs [IfaceTyConBinder]
bndrs NameSet -> NameSet -> NameSet
&&&
IfaceType -> NameSet
freeNamesIfKind IfaceType
res_k NameSet -> NameSet -> NameSet
&&&
IfaceType -> NameSet
freeNamesIfType IfaceType
rhs
freeNamesIfDecl (IfaceFamily { ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
bndrs, ifResKind :: IfaceDecl -> IfaceType
ifResKind = IfaceType
res_k
, ifFamFlav :: IfaceDecl -> IfaceFamTyConFlav
ifFamFlav = IfaceFamTyConFlav
flav })
= [IfaceTyConBinder] -> NameSet
forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs [IfaceTyConBinder]
bndrs NameSet -> NameSet -> NameSet
&&&
IfaceType -> NameSet
freeNamesIfKind IfaceType
res_k NameSet -> NameSet -> NameSet
&&&
IfaceFamTyConFlav -> NameSet
freeNamesIfFamFlav IfaceFamTyConFlav
flav
freeNamesIfDecl (IfaceClass{ ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
bndrs, ifBody :: IfaceDecl -> IfaceClassBody
ifBody = IfaceClassBody
cls_body })
= [IfaceTyConBinder] -> NameSet
forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs [IfaceTyConBinder]
bndrs NameSet -> NameSet -> NameSet
&&&
IfaceClassBody -> NameSet
freeNamesIfClassBody IfaceClassBody
cls_body
freeNamesIfDecl (IfaceAxiom { ifTyCon :: IfaceDecl -> IfaceTyCon
ifTyCon = IfaceTyCon
tc, ifAxBranches :: IfaceDecl -> [IfaceAxBranch]
ifAxBranches = [IfaceAxBranch]
branches })
= IfaceTyCon -> NameSet
freeNamesIfTc IfaceTyCon
tc NameSet -> NameSet -> NameSet
&&&
(IfaceAxBranch -> NameSet) -> [IfaceAxBranch] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceAxBranch -> NameSet
freeNamesIfAxBranch [IfaceAxBranch]
branches
freeNamesIfDecl (IfacePatSyn { ifPatMatcher :: IfaceDecl -> (IfExtName, Bool)
ifPatMatcher = (IfExtName
matcher, Bool
_)
, ifPatBuilder :: IfaceDecl -> Maybe (IfExtName, Bool)
ifPatBuilder = Maybe (IfExtName, Bool)
mb_builder
, ifPatUnivBndrs :: IfaceDecl -> [IfaceForAllSpecBndr]
ifPatUnivBndrs = [IfaceForAllSpecBndr]
univ_bndrs
, ifPatExBndrs :: IfaceDecl -> [IfaceForAllSpecBndr]
ifPatExBndrs = [IfaceForAllSpecBndr]
ex_bndrs
, ifPatProvCtxt :: IfaceDecl -> IfaceContext
ifPatProvCtxt = IfaceContext
prov_ctxt
, ifPatReqCtxt :: IfaceDecl -> IfaceContext
ifPatReqCtxt = IfaceContext
req_ctxt
, ifPatArgs :: IfaceDecl -> IfaceContext
ifPatArgs = IfaceContext
args
, ifPatTy :: IfaceDecl -> IfaceType
ifPatTy = IfaceType
pat_ty
, ifFieldLabels :: IfaceDecl -> [FieldLabel]
ifFieldLabels = [FieldLabel]
lbls })
= IfExtName -> NameSet
unitNameSet IfExtName
matcher NameSet -> NameSet -> NameSet
&&&
NameSet
-> ((IfExtName, Bool) -> NameSet)
-> Maybe (IfExtName, Bool)
-> NameSet
forall b a. b -> (a -> b) -> Maybe a -> b
maybe NameSet
emptyNameSet (IfExtName -> NameSet
unitNameSet (IfExtName -> NameSet)
-> ((IfExtName, Bool) -> IfExtName) -> (IfExtName, Bool) -> NameSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IfExtName, Bool) -> IfExtName
forall a b. (a, b) -> a
fst) Maybe (IfExtName, Bool)
mb_builder NameSet -> NameSet -> NameSet
&&&
[IfaceForAllSpecBndr] -> NameSet
forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs [IfaceForAllSpecBndr]
univ_bndrs NameSet -> NameSet -> NameSet
&&&
[IfaceForAllSpecBndr] -> NameSet
forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs [IfaceForAllSpecBndr]
ex_bndrs NameSet -> NameSet -> NameSet
&&&
IfaceContext -> NameSet
freeNamesIfContext IfaceContext
prov_ctxt NameSet -> NameSet -> NameSet
&&&
IfaceContext -> NameSet
freeNamesIfContext IfaceContext
req_ctxt NameSet -> NameSet -> NameSet
&&&
(IfaceType -> NameSet) -> IfaceContext -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType IfaceContext
args NameSet -> NameSet -> NameSet
&&&
IfaceType -> NameSet
freeNamesIfType IfaceType
pat_ty NameSet -> NameSet -> NameSet
&&&
[IfExtName] -> NameSet
mkNameSet ((FieldLabel -> IfExtName) -> [FieldLabel] -> [IfExtName]
forall a b. (a -> b) -> [a] -> [b]
map FieldLabel -> IfExtName
flSelector [FieldLabel]
lbls)
freeNamesIfClassBody :: IfaceClassBody -> NameSet
freeNamesIfClassBody :: IfaceClassBody -> NameSet
freeNamesIfClassBody IfaceClassBody
IfAbstractClass
= NameSet
emptyNameSet
freeNamesIfClassBody (IfConcreteClass{ ifClassCtxt :: IfaceClassBody -> IfaceContext
ifClassCtxt = IfaceContext
ctxt, ifATs :: IfaceClassBody -> [IfaceAT]
ifATs = [IfaceAT]
ats, ifSigs :: IfaceClassBody -> [IfaceClassOp]
ifSigs = [IfaceClassOp]
sigs })
= IfaceContext -> NameSet
freeNamesIfContext IfaceContext
ctxt NameSet -> NameSet -> NameSet
&&&
(IfaceAT -> NameSet) -> [IfaceAT] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceAT -> NameSet
freeNamesIfAT [IfaceAT]
ats NameSet -> NameSet -> NameSet
&&&
(IfaceClassOp -> NameSet) -> [IfaceClassOp] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceClassOp -> NameSet
freeNamesIfClsSig [IfaceClassOp]
sigs
freeNamesIfAxBranch :: IfaceAxBranch -> NameSet
freeNamesIfAxBranch :: IfaceAxBranch -> NameSet
freeNamesIfAxBranch (IfaceAxBranch { ifaxbTyVars :: IfaceAxBranch -> [IfaceTvBndr]
ifaxbTyVars = [IfaceTvBndr]
tyvars
, ifaxbCoVars :: IfaceAxBranch -> [IfaceIdBndr]
ifaxbCoVars = [IfaceIdBndr]
covars
, ifaxbLHS :: IfaceAxBranch -> IfaceAppArgs
ifaxbLHS = IfaceAppArgs
lhs
, ifaxbRHS :: IfaceAxBranch -> IfaceType
ifaxbRHS = IfaceType
rhs })
= (IfaceTvBndr -> NameSet) -> [IfaceTvBndr] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceTvBndr -> NameSet
freeNamesIfTvBndr [IfaceTvBndr]
tyvars NameSet -> NameSet -> NameSet
&&&
(IfaceIdBndr -> NameSet) -> [IfaceIdBndr] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceIdBndr -> NameSet
freeNamesIfIdBndr [IfaceIdBndr]
covars NameSet -> NameSet -> NameSet
&&&
IfaceAppArgs -> NameSet
freeNamesIfAppArgs IfaceAppArgs
lhs NameSet -> NameSet -> NameSet
&&&
IfaceType -> NameSet
freeNamesIfType IfaceType
rhs
freeNamesIfIdDetails :: IfaceIdDetails -> NameSet
freeNamesIfIdDetails :: IfaceIdDetails -> NameSet
freeNamesIfIdDetails (IfRecSelId Either IfaceTyCon IfaceDecl
tc IfExtName
first_con Bool
_ FieldLabel
fl) =
(IfaceTyCon -> NameSet)
-> (IfaceDecl -> NameSet) -> Either IfaceTyCon IfaceDecl -> NameSet
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either IfaceTyCon -> NameSet
freeNamesIfTc IfaceDecl -> NameSet
freeNamesIfDecl Either IfaceTyCon IfaceDecl
tc NameSet -> NameSet -> NameSet
&&&
IfExtName -> NameSet
unitFV IfExtName
first_con NameSet -> NameSet -> NameSet
&&&
IfExtName -> NameSet
unitFV (FieldLabel -> IfExtName
flSelector FieldLabel
fl)
freeNamesIfIdDetails IfaceIdDetails
IfVanillaId = NameSet
emptyNameSet
freeNamesIfIdDetails (IfWorkerLikeId {}) = NameSet
emptyNameSet
freeNamesIfIdDetails IfaceIdDetails
IfDFunId = NameSet
emptyNameSet
freeNamesIfFamFlav :: IfaceFamTyConFlav -> NameSet
freeNamesIfFamFlav :: IfaceFamTyConFlav -> NameSet
freeNamesIfFamFlav IfaceFamTyConFlav
IfaceOpenSynFamilyTyCon = NameSet
emptyNameSet
freeNamesIfFamFlav IfaceFamTyConFlav
IfaceDataFamilyTyCon = NameSet
emptyNameSet
freeNamesIfFamFlav (IfaceClosedSynFamilyTyCon (Just (IfExtName
ax, [IfaceAxBranch]
br)))
= IfExtName -> NameSet
unitNameSet IfExtName
ax NameSet -> NameSet -> NameSet
&&& (IfaceAxBranch -> NameSet) -> [IfaceAxBranch] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceAxBranch -> NameSet
freeNamesIfAxBranch [IfaceAxBranch]
br
freeNamesIfFamFlav (IfaceClosedSynFamilyTyCon Maybe (IfExtName, [IfaceAxBranch])
Nothing) = NameSet
emptyNameSet
freeNamesIfFamFlav IfaceFamTyConFlav
IfaceAbstractClosedSynFamilyTyCon = NameSet
emptyNameSet
freeNamesIfFamFlav IfaceFamTyConFlav
IfaceBuiltInSynFamTyCon = NameSet
emptyNameSet
freeNamesIfContext :: IfaceContext -> NameSet
freeNamesIfContext :: IfaceContext -> NameSet
freeNamesIfContext = (IfaceType -> NameSet) -> IfaceContext -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType
freeNamesIfAT :: IfaceAT -> NameSet
freeNamesIfAT :: IfaceAT -> NameSet
freeNamesIfAT (IfaceAT IfaceDecl
decl Maybe IfaceType
mb_def)
= IfaceDecl -> NameSet
freeNamesIfDecl IfaceDecl
decl NameSet -> NameSet -> NameSet
&&&
case Maybe IfaceType
mb_def of
Maybe IfaceType
Nothing -> NameSet
emptyNameSet
Just IfaceType
rhs -> IfaceType -> NameSet
freeNamesIfType IfaceType
rhs
freeNamesIfClsSig :: IfaceClassOp -> NameSet
freeNamesIfClsSig :: IfaceClassOp -> NameSet
freeNamesIfClsSig (IfaceClassOp IfExtName
_n IfaceType
ty Maybe (DefMethSpec IfaceType)
dm) = IfaceType -> NameSet
freeNamesIfType IfaceType
ty NameSet -> NameSet -> NameSet
&&& Maybe (DefMethSpec IfaceType) -> NameSet
freeNamesDM Maybe (DefMethSpec IfaceType)
dm
freeNamesDM :: Maybe (DefMethSpec IfaceType) -> NameSet
freeNamesDM :: Maybe (DefMethSpec IfaceType) -> NameSet
freeNamesDM (Just (GenericDM IfaceType
ty)) = IfaceType -> NameSet
freeNamesIfType IfaceType
ty
freeNamesDM Maybe (DefMethSpec IfaceType)
_ = NameSet
emptyNameSet
freeNamesIfConDecls :: IfaceConDecls -> NameSet
freeNamesIfConDecls :: IfaceConDecls -> NameSet
freeNamesIfConDecls (IfDataTyCon Bool
_ [IfaceConDecl]
cs) = (IfaceConDecl -> NameSet) -> [IfaceConDecl] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceConDecl -> NameSet
freeNamesIfConDecl [IfaceConDecl]
cs
freeNamesIfConDecls (IfNewTyCon IfaceConDecl
c) = IfaceConDecl -> NameSet
freeNamesIfConDecl IfaceConDecl
c
freeNamesIfConDecls IfaceConDecls
_ = NameSet
emptyNameSet
freeNamesIfConDecl :: IfaceConDecl -> NameSet
freeNamesIfConDecl :: IfaceConDecl -> NameSet
freeNamesIfConDecl (IfCon { ifConExTCvs :: IfaceConDecl -> [IfaceBndr]
ifConExTCvs = [IfaceBndr]
ex_tvs, ifConCtxt :: IfaceConDecl -> IfaceContext
ifConCtxt = IfaceContext
ctxt
, ifConArgTys :: IfaceConDecl -> [(IfaceType, IfaceType)]
ifConArgTys = [(IfaceType, IfaceType)]
arg_tys
, ifConFields :: IfaceConDecl -> [FieldLabel]
ifConFields = [FieldLabel]
flds
, ifConEqSpec :: IfaceConDecl -> [IfaceTvBndr]
ifConEqSpec = [IfaceTvBndr]
eq_spec
, ifConStricts :: IfaceConDecl -> [IfaceBang]
ifConStricts = [IfaceBang]
bangs })
= (IfaceBndr -> NameSet) -> [IfaceBndr] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceBndr -> NameSet
freeNamesIfBndr [IfaceBndr]
ex_tvs NameSet -> NameSet -> NameSet
&&&
IfaceContext -> NameSet
freeNamesIfContext IfaceContext
ctxt NameSet -> NameSet -> NameSet
&&&
(IfaceType -> NameSet) -> IfaceContext -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType (((IfaceType, IfaceType) -> IfaceType)
-> [(IfaceType, IfaceType)] -> IfaceContext
forall a b. (a -> b) -> [a] -> [b]
map (IfaceType, IfaceType) -> IfaceType
forall a b. (a, b) -> a
fst [(IfaceType, IfaceType)]
arg_tys) NameSet -> NameSet -> NameSet
&&&
(IfaceType -> NameSet) -> IfaceContext -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType (((IfaceType, IfaceType) -> IfaceType)
-> [(IfaceType, IfaceType)] -> IfaceContext
forall a b. (a -> b) -> [a] -> [b]
map (IfaceType, IfaceType) -> IfaceType
forall a b. (a, b) -> b
snd [(IfaceType, IfaceType)]
arg_tys) NameSet -> NameSet -> NameSet
&&&
[IfExtName] -> NameSet
mkNameSet ((FieldLabel -> IfExtName) -> [FieldLabel] -> [IfExtName]
forall a b. (a -> b) -> [a] -> [b]
map FieldLabel -> IfExtName
flSelector [FieldLabel]
flds) NameSet -> NameSet -> NameSet
&&&
(IfaceType -> NameSet) -> IfaceContext -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType ((IfaceTvBndr -> IfaceType) -> [IfaceTvBndr] -> IfaceContext
forall a b. (a -> b) -> [a] -> [b]
map IfaceTvBndr -> IfaceType
forall a b. (a, b) -> b
snd [IfaceTvBndr]
eq_spec) NameSet -> NameSet -> NameSet
&&&
(IfaceBang -> NameSet) -> [IfaceBang] -> NameSet
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceBang -> NameSet
freeNamesIfBang [IfaceBang]
bangs
freeNamesIfBang :: IfaceBang -> NameSet
freeNamesIfBang :: IfaceBang -> NameSet
freeNamesIfBang (IfUnpackCo IfaceCoercion
co) = IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfBang IfaceBang
_ = NameSet
emptyNameSet
freeNamesIfKind :: IfaceType -> NameSet
freeNamesIfKind :: IfaceType -> NameSet
freeNamesIfKind = IfaceType -> NameSet
freeNamesIfType
freeNamesIfAppArgs :: IfaceAppArgs -> NameSet
freeNamesIfAppArgs :: IfaceAppArgs -> NameSet
freeNamesIfAppArgs (IA_Arg IfaceType
t ForAllTyFlag
_ IfaceAppArgs
ts) = IfaceType -> NameSet
freeNamesIfType IfaceType
t NameSet -> NameSet -> NameSet
&&& IfaceAppArgs -> NameSet
freeNamesIfAppArgs IfaceAppArgs
ts
freeNamesIfAppArgs IfaceAppArgs
IA_Nil = NameSet
emptyNameSet
freeNamesIfType :: IfaceType -> NameSet
freeNamesIfType :: IfaceType -> NameSet
freeNamesIfType (IfaceFreeTyVar TyVar
_) = NameSet
emptyNameSet
freeNamesIfType (IfaceTyVar IfLclName
_) = NameSet
emptyNameSet
freeNamesIfType (IfaceAppTy IfaceType
s IfaceAppArgs
t) = IfaceType -> NameSet
freeNamesIfType IfaceType
s NameSet -> NameSet -> NameSet
&&& IfaceAppArgs -> NameSet
freeNamesIfAppArgs IfaceAppArgs
t
freeNamesIfType (IfaceTyConApp IfaceTyCon
tc IfaceAppArgs
ts) = IfaceTyCon -> NameSet
freeNamesIfTc IfaceTyCon
tc NameSet -> NameSet -> NameSet
&&& IfaceAppArgs -> NameSet
freeNamesIfAppArgs IfaceAppArgs
ts
freeNamesIfType (IfaceTupleTy TupleSort
_ PromotionFlag
_ IfaceAppArgs
ts) = IfaceAppArgs -> NameSet
freeNamesIfAppArgs IfaceAppArgs
ts
freeNamesIfType (IfaceLitTy IfaceTyLit
_) = NameSet
emptyNameSet
freeNamesIfType (IfaceForAllTy IfaceForAllBndr
tv IfaceType
t) = IfaceForAllBndr -> NameSet
forall vis. VarBndr IfaceBndr vis -> NameSet
freeNamesIfVarBndr IfaceForAllBndr
tv NameSet -> NameSet -> NameSet
&&& IfaceType -> NameSet
freeNamesIfType IfaceType
t
freeNamesIfType (IfaceFunTy FunTyFlag
_ IfaceType
w IfaceType
s IfaceType
t) = IfaceType -> NameSet
freeNamesIfType IfaceType
s NameSet -> NameSet -> NameSet
&&& IfaceType -> NameSet
freeNamesIfType IfaceType
t NameSet -> NameSet -> NameSet
&&& IfaceType -> NameSet
freeNamesIfType IfaceType
w
freeNamesIfType (IfaceCastTy IfaceType
t IfaceCoercion
c) = IfaceType -> NameSet
freeNamesIfType IfaceType
t NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c
freeNamesIfType (IfaceCoercionTy IfaceCoercion
c) = IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c
freeNamesIfMCoercion :: IfaceMCoercion -> NameSet
freeNamesIfMCoercion :: IfaceMCoercion -> NameSet
freeNamesIfMCoercion IfaceMCoercion
IfaceMRefl = NameSet
emptyNameSet
freeNamesIfMCoercion (IfaceMCo IfaceCoercion
co) = IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfCoercion :: IfaceCoercion -> NameSet
freeNamesIfCoercion :: IfaceCoercion -> NameSet
freeNamesIfCoercion (IfaceReflCo IfaceType
t) = IfaceType -> NameSet
freeNamesIfType IfaceType
t
freeNamesIfCoercion (IfaceGReflCo Role
_ IfaceType
t IfaceMCoercion
mco)
= IfaceType -> NameSet
freeNamesIfType IfaceType
t NameSet -> NameSet -> NameSet
&&& IfaceMCoercion -> NameSet
freeNamesIfMCoercion IfaceMCoercion
mco
freeNamesIfCoercion (IfaceFunCo Role
_ IfaceCoercion
c_mult IfaceCoercion
c1 IfaceCoercion
c2)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c_mult NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c1 NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c2
freeNamesIfCoercion (IfaceTyConAppCo Role
_ IfaceTyCon