{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
module GHC.Iface.Syntax (
module GHC.Iface.Type,
IfaceDecl(..), IfaceFamTyConFlav(..), IfaceClassOp(..), IfaceAT(..),
IfaceConDecl(..), IfaceConDecls(..), IfaceEqSpec,
IfaceExpr(..), IfaceAlt(..), IfaceLetBndr(..), IfaceJoinInfo(..),
IfaceBinding(..), IfaceConAlt(..),
IfaceIdInfo, IfaceIdDetails(..), IfaceUnfolding(..),
IfaceInfoItem(..), IfaceRule(..), IfaceAnnotation(..), IfaceAnnTarget,
IfaceClsInst(..), IfaceFamInst(..), IfaceTickish(..),
IfaceClassBody(..),
IfaceBang(..),
IfaceSrcBang(..), SrcUnpackedness(..), SrcStrictness(..),
IfaceAxBranch(..),
IfaceTyConParent(..),
IfaceCompleteMatch(..),
IfaceLFInfo(..),
IfaceTopBndr,
putIfaceTopBndr, getIfaceTopBndr,
ifaceDeclImplicitBndrs, visibleIfConDecls,
ifaceDeclFingerprints,
freeNamesIfDecl, freeNamesIfRule, freeNamesIfFamInst,
pprIfaceExpr,
pprIfaceDecl,
AltPpr(..), ShowSub(..), ShowHowMuch(..), showToIface, showToHeader
) where
#include "HsVersions.h"
import GHC.Prelude
import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey )
import GHC.Types.Unique ( hasKey )
import GHC.Iface.Type
import GHC.Iface.Recomp.Binary
import GHC.Core( IsOrphan, isOrphan )
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.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.Types.SrcLoc
import GHC.Data.BooleanFormula ( BooleanFormula, pprBooleanFormula, isTrue )
import GHC.Types.Var( VarBndr(..), binderVar, tyVarSpecToBinders )
import GHC.Core.TyCon ( Role (..), Injectivity(..), tyConBndrVisArgFlag )
import GHC.Core.DataCon (SrcStrictness(..), SrcUnpackedness(..))
import GHC.Builtin.Types ( constraintKindTyConName )
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, debugIsOn,
seqList, zipWithEqual )
import Control.Monad
import System.IO.Unsafe
import Control.DeepSeq
infixl 3 &&&
type IfaceTopBndr = Name
getIfaceTopBndr :: BinHandle -> IO IfaceTopBndr
getIfaceTopBndr :: BinHandle -> IO IfExtName
getIfaceTopBndr BinHandle
bh = forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
putIfaceTopBndr :: BinHandle -> IfaceTopBndr -> IO ()
putIfaceTopBndr :: BinHandle -> IfExtName -> IO ()
putIfaceTopBndr BinHandle
bh IfExtName
name =
case BinHandle -> UserData
getUserData BinHandle
bh of
UserData{ ud_put_binding_name :: UserData -> BinHandle -> IfExtName -> IO ()
ud_put_binding_name = BinHandle -> IfExtName -> IO ()
put_binding_name } ->
BinHandle -> IfExtName -> IO ()
put_binding_name BinHandle
bh 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 -> BooleanFormula IfLclName
ifMinDef :: BooleanFormula IfLclName
}
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 [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 IfaceClsInst
= IfaceClsInst { IfaceClsInst -> IfExtName
ifInstCls :: IfExtName,
IfaceClsInst -> [Maybe IfaceTyCon]
ifInstTys :: [Maybe IfaceTyCon],
IfaceClsInst -> IfExtName
ifDFun :: IfExtName,
IfaceClsInst -> OverlapFlag
ifOFlag :: OverlapFlag,
IfaceClsInst -> IsOrphan
ifInstOrph :: IsOrphan }
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 -> IfLclName
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 IfaceAnnotation
= IfaceAnnotation {
IfaceAnnotation -> IfaceAnnTarget
ifAnnotatedTarget :: IfaceAnnTarget,
IfaceAnnotation -> AnnPayload
ifAnnotatedValue :: AnnPayload
}
type IfaceAnnTarget = AnnTarget OccName
data IfaceCompleteMatch = IfaceCompleteMatch [IfExtName] (Maybe IfaceTyCon)
instance Outputable IfaceCompleteMatch where
ppr :: IfaceCompleteMatch -> SDoc
ppr (IfaceCompleteMatch [IfExtName]
cls Maybe IfaceTyCon
mtc) = String -> SDoc
text String
"COMPLETE" SDoc -> SDoc -> SDoc
<> SDoc
colon SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr [IfExtName]
cls SDoc -> SDoc -> SDoc
<+> case Maybe IfaceTyCon
mtc of
Maybe IfaceTyCon
Nothing -> SDoc
empty
Just IfaceTyCon
tc -> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceTyCon
tc
type IfaceIdInfo = [IfaceInfoItem]
data IfaceInfoItem
= HsArity Arity
| HsStrictness StrictSig
| HsCpr CprSig
| HsInline InlinePragma
| HsUnfold Bool
IfaceUnfolding
| HsNoCafRefs
| HsLevity
| HsLFInfo IfaceLFInfo
data IfaceUnfolding
= IfCoreUnfold Bool IfaceExpr
| IfCompulsory IfaceExpr
| IfInlineRule Arity
Bool
Bool
IfaceExpr
| IfDFunUnfold [IfaceBndr] [IfaceExpr]
data IfaceIdDetails
= IfVanillaId
| IfRecSelId (Either IfaceTyCon IfaceDecl) Bool
| 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
text String
"LFReEntrant" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Int
arity
ppr (IfLFThunk Bool
updatable Bool
mb_fun) =
String -> SDoc
text String
"LFThunk" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens
(String -> SDoc
text String
"updatable=" SDoc -> SDoc -> SDoc
<> forall a. Outputable a => a -> SDoc
ppr Bool
updatable SDoc -> SDoc -> SDoc
<+>
String -> SDoc
text String
"might_be_function=" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Bool
mb_fun)
ppr (IfLFCon IfExtName
con) =
String -> SDoc
text String
"LFCon" SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
brackets (forall a. Outputable a => a -> SDoc
ppr IfExtName
con)
ppr IfaceLFInfo
IfLFUnlifted =
String -> SDoc
text String
"LFUnlifted"
ppr (IfLFUnknown Bool
fun_flag) =
String -> SDoc
text String
"LFUnknown" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Bool
fun_flag
instance Binary IfaceLFInfo where
put_ :: BinHandle -> IfaceLFInfo -> IO ()
put_ BinHandle
bh (IfLFReEntrant Int
arity) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
0
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Int
arity
put_ BinHandle
bh (IfLFThunk Bool
updatable Bool
mb_fun) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
1
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Bool
updatable
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Bool
mb_fun
put_ BinHandle
bh (IfLFCon IfExtName
con_name) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
2
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfExtName
con_name
put_ BinHandle
bh (IfLFUnknown Bool
fun_flag) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
3
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Bool
fun_flag
put_ BinHandle
bh IfaceLFInfo
IfLFUnlifted =
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
4
get :: BinHandle -> IO IfaceLFInfo
get BinHandle
bh = do
Word8
tag <- BinHandle -> IO Word8
getByte BinHandle
bh
case Word8
tag of
Word8
0 -> Int -> IfaceLFInfo
IfLFReEntrant forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Word8
1 -> Bool -> Bool -> IfaceLFInfo
IfLFThunk forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Binary a => BinHandle -> IO a
get BinHandle
bh forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Word8
2 -> IfExtName -> IfaceLFInfo
IfLFCon forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Word8
3 -> Bool -> IfaceLFInfo
IfLFUnknown forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Word8
4 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure IfaceLFInfo
IfLFUnlifted
Word8
_ -> forall a. String -> a
panic String
"Invalid byte"
visibleIfConDecls :: IfaceConDecls -> [IfaceConDecl]
visibleIfConDecls :: IfaceConDecls -> [IfaceConDecl]
visibleIfConDecls IfaceConDecls
IfAbstractTyCon = []
visibleIfConDecls (IfDataTyCon [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
IfaceConDecls
IfAbstractTyCon -> []
IfNewTyCon IfaceConDecl
cd -> OccName -> OccName
mkNewTyCoOcc (forall name. HasOccName name => name -> OccName
occName IfExtName
tc_name) forall a. a -> [a] -> [a]
: IfaceConDecl -> [OccName]
ifaceConDeclImplicitBndrs IfaceConDecl
cd
IfDataTyCon [IfaceConDecl]
cds -> 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 forall a. [a] -> [a] -> [a]
++
[OccName
dc_occ, OccName
dcww_occ] forall a. [a] -> [a] -> [a]
++
[forall name. HasOccName name => name -> OccName
occName (IfaceDecl -> IfExtName
ifName IfaceDecl
at) | IfaceAT IfaceDecl
at Maybe IfaceType
_ <- [IfaceAT]
ats ] forall a. [a] -> [a] -> [a]
++
[Int -> OccName -> OccName
mkSuperDictSelOcc Int
n OccName
cls_tc_occ | Int
n <- [Int
1..Int
n_ctxt]] forall a. [a] -> [a] -> [a]
++
[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 = forall name. HasOccName name => name -> OccName
occName IfExtName
cls_tc_name
n_ctxt :: Int
n_ctxt = forall (t :: * -> *) a. Foldable t => t a -> Int
length IfaceContext
sc_ctxt
n_sigs :: Int
n_sigs = 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 forall a. Num a => a -> a -> a
+ Int
n_ctxt 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 })
= [forall name. HasOccName name => name -> OccName
occName IfExtName
con_name, OccName
work_occ] forall a. [a] -> [a] -> [a]
++ [OccName]
wrap_occs
where
con_occ :: OccName
con_occ = 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
= (forall a. NamedThing a => a -> OccName
getOccName IfaceDecl
decl, Fingerprint
hash) 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' =
forall a. IO a -> a
unsafeDupablePerformIO
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
Binary a =>
(BinHandle -> IfExtName -> IO ()) -> a -> IO Fingerprint
computeFingerprint (forall a. String -> a
panic String
"ifaceDeclFingerprints")
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 IfaceExpr
| IfaceCast IfaceExpr IfaceCoercion
| IfaceLit Literal
| IfaceFCall ForeignCall IfaceType
| IfaceTick IfaceTickish IfaceExpr
data IfaceTickish
= IfaceHpcTick Module Int
| IfaceSCC CostCentre Bool Bool
| IfaceSource RealSrcSpan String
data IfaceAlt = IfaceAlt IfaceConAlt [IfLclName] IfaceExpr
data IfaceConAlt = IfaceDefault
| IfaceDataAlt IfExtName
| IfaceLitAlt Literal
data IfaceBinding
= IfaceNonRec IfaceLetBndr IfaceExpr
| IfaceRec [(IfaceLetBndr, IfaceExpr)]
data IfaceLetBndr = IfLetBndr IfLclName IfaceType IfaceIdInfo IfaceJoinInfo
data IfaceJoinInfo = IfaceNotJoinPoint
| IfaceJoinPoint JoinArity
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 })
= ASSERT2( null _cvs, pp_tc $$ ppr _cvs )
SDoc -> Int -> SDoc -> SDoc
hang SDoc
ppr_binders Int
2 (SDoc -> Int -> SDoc -> SDoc
hang SDoc
pp_lhs Int
2 (SDoc
equals SDoc -> SDoc -> 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
<+>
[IfaceForAllBndr] -> SDoc
pprUserIfaceForAll (forall a b. (a -> b) -> [a] -> [b]
map (ArgFlag -> IfaceTvBndr -> IfaceForAllBndr
mkIfaceForAllTvBndr ArgFlag
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 forall a b. (a -> b) -> a -> b
$
String -> SDoc
text String
"{-" SDoc -> SDoc -> SDoc
<+> (String -> SDoc
text String
"#" SDoc -> SDoc -> SDoc
<> forall a. Outputable a => a -> SDoc
ppr Int
idx) SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"-}"
maybe_incomps :: SDoc
maybe_incomps
= (SDocContext -> Bool) -> SDoc -> SDoc
ppWhenOption SDocContext -> Bool
sdocPrintAxiomIncomps forall a b. (a -> b) -> a -> b
$
Bool -> SDoc -> SDoc
ppWhen (forall (f :: * -> *) a. Foldable f => f a -> Bool
notNull [Int]
incomps) forall a b. (a -> b) -> a -> b
$
String -> SDoc
text String
"--" SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"incompatible with:"
SDoc -> SDoc -> SDoc
<+> forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (\Int
incomp -> String -> SDoc
text String
"#" SDoc -> SDoc -> SDoc
<> forall a. Outputable a => a -> SDoc
ppr Int
incomp) [Int]
incomps
instance Outputable IfaceAnnotation where
ppr :: IfaceAnnotation -> SDoc
ppr (IfaceAnnotation IfaceAnnTarget
target AnnPayload
value) = forall a. Outputable a => a -> SDoc
ppr IfaceAnnTarget
target SDoc -> SDoc -> SDoc
<+> SDoc
colon SDoc -> SDoc -> 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 = 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 = 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 = forall a. NamedThing a => a -> OccName
getOccName
instance Outputable IfaceDecl where
ppr :: IfaceDecl -> SDoc
ppr = ShowSub -> IfaceDecl -> SDoc
pprIfaceDecl ShowSub
showToIface
data ShowSub
= ShowSub
{ ShowSub -> ShowHowMuch
ss_how_much :: ShowHowMuch
, ShowSub -> ShowForAllFlag
ss_forall :: ShowForAllFlag }
newtype AltPpr = AltPpr (Maybe (OccName -> SDoc))
data ShowHowMuch
= AltPpr
| ShowSome [OccName] AltPpr
| ShowIface
instance Outputable ShowHowMuch where
ppr :: ShowHowMuch -> SDoc
ppr (ShowHeader AltPpr
_) = String -> SDoc
text String
"ShowHeader"
ppr ShowHowMuch
ShowIface = String -> SDoc
text String
"ShowIface"
ppr (ShowSome [OccName]
occs AltPpr
_) = String -> SDoc
text String
"ShowSome" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr [OccName]
occs
showToHeader :: ShowSub
= ShowSub { ss_how_much :: ShowHowMuch
ss_how_much = AltPpr -> ShowHowMuch
ShowHeader forall a b. (a -> b) -> a -> b
$ Maybe (OccName -> SDoc) -> AltPpr
AltPpr 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
Outputable.empty
ppShowAllSubs :: ShowSub -> SDoc -> SDoc
ppShowAllSubs :: ShowSub -> SDoc -> SDoc
ppShowAllSubs (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowSome [] 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
Outputable.empty
ppShowRhs :: ShowSub -> SDoc -> SDoc
ppShowRhs :: ShowSub -> SDoc -> SDoc
ppShowRhs (ShowSub { ss_how_much :: ShowSub -> ShowHowMuch
ss_how_much = ShowHeader AltPpr
_ }) SDoc
_ = SDoc
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 (OccName
n:[OccName]
_) AltPpr
_ }) n
thing = OccName
n forall a. Eq a => a -> a -> Bool
== 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
= forall a b. (a, b) -> b
snd (forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Maybe SDoc -> (Bool, [SDoc]) -> (Bool, [SDoc])
go (Bool
False, []) [Maybe SDoc]
xs)
where
go :: Maybe SDoc -> (Bool, [SDoc]) -> (Bool, [SDoc])
go (Just SDoc
doc) (Bool
_, [SDoc]
so_far) = (Bool
False, SDoc
doc forall a. a -> [a] -> [a]
: [SDoc]
so_far)
go Maybe SDoc
Nothing (Bool
True, [SDoc]
so_far) = (Bool
True, [SDoc]
so_far)
go Maybe SDoc
Nothing (Bool
False, [SDoc]
so_far) = (Bool
True, String -> SDoc
text String
"..." forall a. a -> [a] -> [a]
: [SDoc]
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 (forall a. Eq a => a -> a -> Bool
== Role
Nominal)
(ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (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) (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
vcat [ SDoc
pp_roles
, SDoc
pp_ki_sig
, SDoc
pp_nd SDoc -> SDoc -> SDoc
<+> SDoc
pp_lhs SDoc -> SDoc -> SDoc
<+> SDoc
pp_kind SDoc -> SDoc -> SDoc
<+> SDoc
pp_where
, Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
vcat [SDoc]
pp_cons)
, Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$ ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss SDoc
pp_extra ]
| Bool
otherwise = [SDoc] -> SDoc
vcat [ SDoc
pp_roles
, SDoc
pp_ki_sig
, SDoc -> Int -> SDoc -> SDoc
hang (SDoc
pp_nd SDoc -> SDoc -> SDoc
<+> SDoc
pp_lhs) Int
2 ([SDoc] -> SDoc
add_bars [SDoc]
pp_cons)
, Int -> SDoc -> SDoc
nest Int
2 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 = [forall var argf. var -> argf -> VarBndr var argf
Bndr (forall tv argf. VarBndr tv argf -> tv
binderVar IfaceTyConBinder
tc_bndr) ArgFlag
Specified | IfaceTyConBinder
tc_bndr <- [IfaceTyConBinder]
binders]
cons :: [IfaceConDecl]
cons = IfaceConDecls -> [IfaceConDecl]
visibleIfConDecls IfaceConDecls
condecls
pp_where :: SDoc
pp_where = Bool -> SDoc -> SDoc
ppWhen (Bool
gadt Bool -> Bool -> Bool
&& Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceConDecl]
cons)) forall a b. (a -> b) -> a -> b
$ String -> SDoc
text String
"where"
pp_cons :: [SDoc]
pp_cons = [Maybe SDoc] -> [SDoc]
ppr_trim (forall a b. (a -> b) -> [a] -> [b]
map IfaceConDecl -> Maybe SDoc
show_con [IfaceConDecl]
cons) :: [SDoc]
pp_kind :: SDoc
pp_kind = Bool -> SDoc -> SDoc
ppUnless (if Bool
ki_sig_printable
then IfaceType -> Bool
isIfaceTauType IfaceType
kind
else IfaceType -> Bool
isIfaceLiftedTypeKind IfaceType
kind)
(SDoc
dcolon SDoc -> SDoc -> 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
text String
"instance" SDoc -> SDoc -> SDoc
<+> SDoc
pp_data_inst_forall
SDoc -> SDoc -> SDoc
<+> IfaceTyConParent -> SDoc
pprIfaceTyConParent IfaceTyConParent
parent
pp_roles :: SDoc
pp_roles
| Bool
is_data_instance = SDoc
empty
| Bool
otherwise = (Role -> Bool) -> SDoc -> [IfaceTyConBinder] -> [Role] -> SDoc
pprRoles (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
ppWhen Bool
ki_sig_printable 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) (forall name. HasOccName name => name -> OccName
occName IfExtName
tycon)
add_bars :: [SDoc] -> SDoc
add_bars [] = SDoc
Outputable.empty
add_bars (SDoc
c:[SDoc]
cs) = [SDoc] -> SDoc
sep ((SDoc
equals SDoc -> SDoc -> SDoc
<+> SDoc
c) forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map (SDoc
vbar SDoc -> SDoc -> SDoc
<+>) [SDoc]
cs)
ok_con :: IfaceConDecl -> Bool
ok_con IfaceConDecl
dc = forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfaceConDecl
dc Bool -> Bool -> Bool
|| forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss 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 = forall a. a -> Maybe a
Just 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 = forall a. Maybe a
Nothing
pp_nd :: SDoc
pp_nd = case IfaceConDecls
condecls of
IfAbstractTyCon{} -> String -> SDoc
text String
"data"
IfDataTyCon{} -> String -> SDoc
text String
"data"
IfNewTyCon{} -> String -> SDoc
text String
"newtype"
pp_extra :: SDoc
pp_extra = [SDoc] -> SDoc
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
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
text String
"class" SDoc -> SDoc -> SDoc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
clas [IfaceTyConBinder]
binders SDoc -> SDoc -> 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 -> BooleanFormula IfLclName
ifMinDef = BooleanFormula IfLclName
minDef
}})
= [SDoc] -> SDoc
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
text String
"class" SDoc -> SDoc -> SDoc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig IfaceContext
context ShowSub
ss IfExtName
clas [IfaceTyConBinder]
binders SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => [FunDep a] -> SDoc
pprFundeps [FunDep IfLclName]
fds SDoc -> SDoc -> SDoc
<+> SDoc
pp_where
, Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
vcat [ [SDoc] -> SDoc
vcat [SDoc]
asocs, [SDoc] -> SDoc
vcat [SDoc]
dsigs
, ShowSub -> SDoc -> SDoc
ppShowAllSubs ShowSub
ss (BooleanFormula IfLclName -> SDoc
pprMinDef BooleanFormula IfLclName
minDef)])]
where
pp_where :: SDoc
pp_where = ShowSub -> SDoc -> SDoc
ppShowRhs ShowSub
ss forall a b. (a -> b) -> a -> b
$ Bool -> SDoc -> SDoc
ppUnless (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceClassOp]
sigs Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceAT]
ats) (String -> SDoc
text String
"where")
asocs :: [SDoc]
asocs = [Maybe SDoc] -> [SDoc]
ppr_trim forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map IfaceAT -> Maybe SDoc
maybeShowAssoc [IfaceAT]
ats
dsigs :: [SDoc]
dsigs = [Maybe SDoc] -> [SDoc]
ppr_trim forall a b. (a -> b) -> a -> b
$ 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
_)
| forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfaceDecl
d = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ ShowSub -> IfaceAT -> SDoc
pprIfaceAT ShowSub
ss IfaceAT
asc
| Bool
otherwise = forall a. Maybe a
Nothing
maybeShowSig :: IfaceClassOp -> Maybe SDoc
maybeShowSig :: IfaceClassOp -> Maybe SDoc
maybeShowSig IfaceClassOp
sg
| forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfaceClassOp
sg = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ ShowSub -> IfaceClassOp -> SDoc
pprIfaceClassOp ShowSub
ss IfaceClassOp
sg
| Bool
otherwise = forall a. Maybe a
Nothing
pprMinDef :: BooleanFormula IfLclName -> SDoc
pprMinDef :: BooleanFormula IfLclName -> SDoc
pprMinDef BooleanFormula IfLclName
minDef = Bool -> SDoc -> SDoc
ppUnless (forall a. BooleanFormula a -> Bool
isTrue BooleanFormula IfLclName
minDef) forall a b. (a -> b) -> a -> b
$
String -> SDoc
text String
"{-# MINIMAL" SDoc -> SDoc -> SDoc
<+>
forall a.
(Rational -> a -> SDoc) -> Rational -> BooleanFormula a -> SDoc
pprBooleanFormula
(\Rational
_ IfLclName
def -> Bool -> SDoc -> SDoc
cparen (IfLclName -> Bool
isLexSym IfLclName
def) (forall a. Outputable a => a -> SDoc
ppr IfLclName
def)) Rational
0 BooleanFormula IfLclName
minDef SDoc -> SDoc -> SDoc
<+>
String -> SDoc
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
vcat [ SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
name_doc ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
res_kind)
, SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"type" SDoc -> SDoc -> SDoc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
tc [IfaceTyConBinder]
binders SDoc -> SDoc -> SDoc
<+> SDoc
equals)
Int
2 ([SDoc] -> SDoc
sep [ [IfaceForAllBndr] -> SDoc
pprIfaceForAll [IfaceForAllBndr]
tvs, IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
theta, SDoc
ppr_tau
, Bool -> SDoc -> SDoc
ppUnless (IfaceType -> Bool
isIfaceLiftedTypeKind IfaceType
res_kind) (SDoc
dcolon SDoc -> SDoc -> 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) (forall name. HasOccName name => name -> OccName
occName IfExtName
tc)
ppr_tau :: SDoc
ppr_tau | IfExtName
tc forall a. Uniquable a => a -> Unique -> Bool
`hasKey` Unique
liftedTypeKindTyConKey Bool -> Bool -> Bool
||
IfExtName
tc forall a. Uniquable a => a -> Unique -> Bool
`hasKey` Unique
unrestrictedFunTyConKey
= (SDocContext -> SDocContext) -> SDoc -> SDoc
updSDocContext (\SDocContext
ctx -> SDocContext
ctx { sdocPrintTypeAbbreviations :: Bool
sdocPrintTypeAbbreviations = Bool
False }) forall a b. (a -> b) -> a -> b
$ forall a. Outputable a => a -> SDoc
ppr IfaceType
tau
| Bool
otherwise = 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
vcat [ SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
name_doc ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
res_kind)
, String -> SDoc
text String
"data family" SDoc -> SDoc -> SDoc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
tycon [IfaceTyConBinder]
binders
]
| Bool
otherwise
= [SDoc] -> SDoc
vcat [ SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
name_doc ([IfaceTyConBinder] -> IfaceType -> IfaceType
mkIfaceTyConKind [IfaceTyConBinder]
binders IfaceType
res_kind)
, SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"type family"
SDoc -> SDoc -> SDoc
<+> SuppressBndrSig
-> IfaceContext
-> ShowSub
-> IfExtName
-> [IfaceTyConBinder]
-> SDoc
pprIfaceDeclHead SuppressBndrSig
suppress_bndr_sig [] ShowSub
ss IfExtName
tycon [IfaceTyConBinder]
binders
SDoc -> SDoc -> SDoc
<+> ShowSub -> SDoc -> SDoc
ppShowRhs ShowSub
ss (IfaceFamTyConFlav -> SDoc
pp_where IfaceFamTyConFlav
rhs))
Int
2 (Maybe IfLclName -> Injectivity -> SDoc
pp_inj Maybe IfLclName
res_var Injectivity
inj SDoc -> SDoc -> SDoc
<+> ShowSub -> SDoc -> SDoc
ppShowRhs ShowSub
ss (IfaceFamTyConFlav -> SDoc
pp_rhs IfaceFamTyConFlav
rhs))
SDoc -> SDoc -> SDoc
$$
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) (forall name. HasOccName name => name -> OccName
occName IfExtName
tycon)
pp_where :: IfaceFamTyConFlav -> SDoc
pp_where (IfaceClosedSynFamilyTyCon {}) = String -> SDoc
text String
"where"
pp_where IfaceFamTyConFlav
_ = SDoc
empty
pp_inj :: Maybe IfLclName -> Injectivity -> SDoc
pp_inj Maybe IfLclName
Nothing Injectivity
_ = SDoc
empty
pp_inj (Just IfLclName
res) Injectivity
inj
| Injective [Bool]
injectivity <- Injectivity
inj = [SDoc] -> SDoc
hsep [ SDoc
equals, forall a. Outputable a => a -> SDoc
ppr IfLclName
res
, IfLclName -> [Bool] -> SDoc
pp_inj_cond IfLclName
res [Bool]
injectivity]
| Bool
otherwise = [SDoc] -> SDoc
hsep [ SDoc
equals, forall a. Outputable a => a -> SDoc
ppr IfLclName
res ]
pp_inj_cond :: IfLclName -> [Bool] -> SDoc
pp_inj_cond IfLclName
res [Bool]
inj = case forall a. [Bool] -> [a] -> [a]
filterByList [Bool]
inj [IfaceTyConBinder]
binders of
[] -> SDoc
empty
[IfaceTyConBinder]
tvs -> [SDoc] -> SDoc
hsep [SDoc
vbar, forall a. Outputable a => a -> SDoc
ppr IfLclName
res, String -> SDoc
text String
"->", forall a. Outputable a => [a] -> SDoc
interppSP (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
text String
"data")
pp_rhs IfaceFamTyConFlav
IfaceOpenSynFamilyTyCon
= ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
text String
"open")
pp_rhs IfaceFamTyConFlav
IfaceAbstractClosedSynFamilyTyCon
= ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
text String
"closed, abstract")
pp_rhs (IfaceClosedSynFamilyTyCon {})
= SDoc
empty
pp_rhs IfaceFamTyConFlav
IfaceBuiltInSynFamTyCon
= ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
text String
"built-in")
pp_branches :: IfaceFamTyConFlav -> SDoc
pp_branches (IfaceClosedSynFamilyTyCon (Just (IfExtName
ax, [IfaceAxBranch]
brs)))
= [SDoc] -> SDoc
vcat (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)
(forall name. HasOccName name => name -> OccName
occName IfExtName
tycon))
) forall a b. (a -> b) -> a -> b
$ forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0..] [IfaceAxBranch]
brs)
SDoc -> SDoc -> SDoc
$$ ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (String -> SDoc
text String
"axiom" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfExtName
ax)
pp_branches IfaceFamTyConFlav
_ = SDoc
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,
ifPatTy :: IfaceDecl -> IfaceType
ifPatTy = IfaceType
pat_ty} )
= (SDocContext -> SDoc) -> SDoc
sdocWithContext SDocContext -> SDoc
mk_msg
where
mk_msg :: SDocContext -> SDoc
mk_msg SDocContext
sdocCtx
= SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"pattern" SDoc -> SDoc -> SDoc
<+> forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc IfExtName
name)
Int
2 (SDoc
dcolon SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
sep [SDoc
univ_msg
, IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
req_ctxt
, Bool -> SDoc -> SDoc
ppWhen Bool
insert_empty_ctxt forall a b. (a -> b) -> a -> b
$ SDoc -> SDoc
parens SDoc
empty SDoc -> SDoc -> SDoc
<+> SDoc
darrow
, SDoc
ex_msg
, IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
prov_ctxt
, IfaceType -> SDoc
pprIfaceType forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (AnonArgFlag -> IfaceType -> IfaceType -> IfaceType -> IfaceType
IfaceFunTy AnonArgFlag
VisArg IfaceType
many_ty) IfaceType
pat_ty IfaceContext
arg_tys ])
where
univ_msg :: SDoc
univ_msg = [IfaceForAllBndr] -> SDoc
pprUserIfaceForAll forall a b. (a -> b) -> a -> b
$ forall a. [VarBndr a Specificity] -> [VarBndr a ArgFlag]
tyVarSpecToBinders [IfaceForAllSpecBndr]
univ_bndrs
ex_msg :: SDoc
ex_msg = [IfaceForAllBndr] -> SDoc
pprUserIfaceForAll forall a b. (a -> b) -> a -> b
$ forall a. [VarBndr a Specificity] -> [VarBndr a ArgFlag]
tyVarSpecToBinders [IfaceForAllSpecBndr]
ex_bndrs
insert_empty_ctxt :: Bool
insert_empty_ctxt = forall (t :: * -> *) a. Foldable t => t a -> Bool
null IfaceContext
req_ctxt
Bool -> Bool -> Bool
&& Bool -> Bool
not (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
vcat [ SDoc -> Int -> SDoc -> SDoc
hang (ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (forall name. HasOccName name => name -> OccName
occName IfExtName
var) SDoc -> SDoc -> SDoc
<+> SDoc
dcolon)
Int
2 (ShowForAllFlag -> IfaceType -> SDoc
pprIfaceSigmaType (ShowSub -> ShowForAllFlag
ss_forall ShowSub
ss) IfaceType
ty)
, ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (forall a. Outputable a => a -> SDoc
ppr IfaceIdDetails
details)
, ShowSub -> SDoc -> SDoc
ppShowIface ShowSub
ss (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
text String
"axiom" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfExtName
name SDoc -> SDoc -> SDoc
<+> SDoc
dcolon)
Int
2 ([SDoc] -> SDoc
vcat forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> [(a, b)] -> [c]
unzipWith (SDoc -> Int -> IfaceAxBranch -> SDoc
pprAxBranch (forall a. Outputable a => a -> SDoc
ppr IfaceTyCon
tycon)) forall a b. (a -> b) -> a -> b
$ 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
Outputable.empty
pprCType (Just CType
cType) = String -> SDoc
text String
"C type:" SDoc -> SDoc -> 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
= forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocPrintExplicitKinds forall a b. (a -> b) -> a -> b
$ \Bool
print_kinds ->
let froles :: [Role]
froles = forall a. PrintExplicitKinds -> [IfaceTyConBinder] -> [a] -> [a]
suppressIfaceInvisibles (Bool -> PrintExplicitKinds
PrintExplicitKinds Bool
print_kinds) [IfaceTyConBinder]
bndrs [Role]
roles
in Bool -> SDoc -> SDoc
ppUnless (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Role -> Bool
suppress_if [Role]
froles Bool -> Bool -> Bool
|| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Role]
froles) forall a b. (a -> b) -> a -> b
$
String -> SDoc
text String
"type role" SDoc -> SDoc -> SDoc
<+> SDoc
tyCon SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
hsep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [Role]
froles)
pprStandaloneKindSig :: SDoc -> IfaceType -> SDoc
pprStandaloneKindSig :: SDoc -> IfaceType -> SDoc
pprStandaloneKindSig SDoc
tyCon IfaceType
ty = String -> SDoc
text String
"type" SDoc -> SDoc -> SDoc
<+> SDoc
tyCon SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"::" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceType
ty
pprInfixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
pprInfixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
pprInfixIfDeclBndr (ShowSome [OccName]
_ (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) (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 [OccName]
_ (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 (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
$$ SDoc
generic_dm
where
generic_dm :: SDoc
generic_dm | Just (GenericDM IfaceType
dm_ty) <- Maybe (DefMethSpec IfaceType)
dm
= String -> SDoc
text String
"default" SDoc -> SDoc -> SDoc
<+> IfExtName -> IfaceType -> SDoc
pp_sig IfExtName
n IfaceType
dm_ty
| Bool
otherwise
= SDoc
empty
pp_sig :: IfExtName -> IfaceType -> SDoc
pp_sig IfExtName
n IfaceType
ty
= ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (forall name. HasOccName name => name -> OccName
occName IfExtName
n)
SDoc -> SDoc -> SDoc
<+> SDoc
dcolon
SDoc -> SDoc -> SDoc
<+> 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
vcat [ ShowSub -> IfaceDecl -> SDoc
pprIfaceDecl ShowSub
ss IfaceDecl
d
, case Maybe IfaceType
mb_def of
Maybe IfaceType
Nothing -> SDoc
Outputable.empty
Just IfaceType
rhs -> Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$
String -> SDoc
text String
"Default:" SDoc -> SDoc -> 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
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
= forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocPrintExplicitKinds forall a b. (a -> b) -> a -> b
$ \Bool
print_kinds ->
[SDoc] -> SDoc
sep [ IfaceContext -> SDoc
pprIfaceContextArr IfaceContext
context
, ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr (ShowSub -> ShowHowMuch
ss_how_much ShowSub
ss) (forall name. HasOccName name => name -> OccName
occName IfExtName
tc_occ)
SDoc -> SDoc -> SDoc
<+> SuppressBndrSig -> [IfaceTyConBinder] -> SDoc
pprIfaceTyConBinders SuppressBndrSig
suppress_sig
(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
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> 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 (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FieldLabel]
fields) = SDoc
pp_prefix_con SDoc -> SDoc -> SDoc
<+> SDoc
pp_field_args
| Bool
is_infix
, [SDoc
ty1, SDoc
ty2] <- [SDoc]
pp_args
= [SDoc] -> SDoc
sep [ SDoc
ty1
, ShowHowMuch -> OccName -> SDoc
pprInfixIfDeclBndr ShowHowMuch
how_much (forall name. HasOccName name => name -> OccName
occName IfExtName
name)
, SDoc
ty2]
| Bool
otherwise = SDoc
pp_prefix_con SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
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 = forall a b. [a] -> [b] -> [(a, b)]
zip [IfaceBang]
stricts (forall a b. (a -> b) -> [a] -> [b]
map 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 (forall name. HasOccName name => name -> OccName
occName IfExtName
name)
ex_tvbs :: [IfaceForAllSpecBndr]
ex_tvbs = 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 | forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FieldLabel]
fields
= case [SDoc]
pp_args forall a. [a] -> [a] -> [a]
++ [SDoc
pp_gadt_res_ty] of
(SDoc
t:[SDoc]
ts) -> [SDoc] -> SDoc
fsep (SDoc
t forall a. a -> [a] -> [a]
: forall a b c. String -> (a -> b -> c) -> [a] -> [b] -> [c]
zipWithEqual String
"pprIfaceConDecl" (\(IfaceType
w,IfaceType
_) SDoc
d -> IfaceType -> SDoc
ppr_arr IfaceType
w SDoc -> SDoc -> SDoc
<+> SDoc
d) [(IfaceType, IfaceType)]
arg_tys [SDoc]
ts)
[] -> forall a. String -> a
panic String
"pp_con_taus"
| Bool
otherwise
= [SDoc] -> SDoc
sep [SDoc
pp_field_args, SDoc
arrow SDoc -> SDoc -> SDoc
<+> SDoc
pp_gadt_res_ty]
ppr_arr :: IfaceType -> SDoc
ppr_arr IfaceType
w = forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocLinearTypes (\Bool
linearTypes -> if Bool
linearTypes
then IfaceType -> SDoc
ppr_fun_arrow IfaceType
w
else SDoc
arrow)
ppr_bang :: IfaceBang -> SDoc
ppr_bang IfaceBang
IfNoBang = SDoc -> SDoc
whenPprDebug forall a b. (a -> b) -> a -> b
$ Char -> SDoc
char Char
'_'
ppr_bang IfaceBang
IfStrict = Char -> SDoc
char Char
'!'
ppr_bang IfaceBang
IfUnpack = String -> SDoc
text String
"{-# UNPACK #-}"
ppr_bang (IfUnpackCo IfaceCoercion
co) = String -> SDoc
text String
"! {-# UNPACK #-}" SDoc -> SDoc -> SDoc
<>
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 (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
<> 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 = 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
braces forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
sep forall a b. (a -> b) -> a -> b
$ SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma forall a b. (a -> b) -> a -> b
$ [Maybe SDoc] -> [SDoc]
ppr_trim forall a b. (a -> b) -> a -> b
$
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
| forall n. HasOccName n => ShowSub -> n -> Bool
showSub ShowSub
ss IfExtName
sel = forall a. a -> Maybe a
Just (ShowHowMuch -> OccName -> SDoc
pprPrefixIfDeclBndr ShowHowMuch
how_much OccName
occ
SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> (IfaceBang, IfaceType) -> SDoc
pprFieldArgTy (IfaceBang, IfaceType)
bty)
| Bool
otherwise = forall a. Maybe a
Nothing
where
sel :: IfExtName
sel = FieldLabel -> IfExtName
flSelector FieldLabel
lbl
occ :: OccName
occ = IfLclName -> OccName
mkVarOccFS (FieldLabel -> IfLclName
flLabel FieldLabel
lbl)
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 (forall name. HasOccName name => name -> OccName
occName IfExtName
tycon)
SDoc -> SDoc -> SDoc
<+> 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 -> ArgFlag -> IfaceAppArgs -> IfaceAppArgs
IA_Arg (IfLclName -> IfaceType
IfaceTyVar (IfaceBndr -> IfLclName
ifaceBndrName IfaceBndr
bndr)) (TyConBndrVis -> ArgFlag
tyConBndrVisArgFlag TyConBndrVis
vis)
([IfaceTyConBinder] -> IfaceAppArgs
mk_tc_app_args [IfaceTyConBinder]
tc_bndrs)
instance Outputable IfaceRule where
ppr :: IfaceRule -> SDoc
ppr (IfaceRule { ifRuleName :: IfaceRule -> IfLclName
ifRuleName = IfLclName
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
sep [ [SDoc] -> SDoc
hsep [ IfLclName -> SDoc
pprRuleName IfLclName
name
, if IsOrphan -> Bool
isOrphan IsOrphan
orph then String -> SDoc
text String
"[orphan]" else SDoc
Outputable.empty
, forall a. Outputable a => a -> SDoc
ppr Activation
act
, SDoc
pp_foralls ]
, Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
sep [forall a. Outputable a => a -> SDoc
ppr IfExtName
fn SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
sep (forall a b. (a -> b) -> [a] -> [b]
map IfaceExpr -> SDoc
pprParendIfaceExpr [IfaceExpr]
args),
String -> SDoc
text String
"=" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceExpr
rhs]) ]
where
pp_foralls :: SDoc
pp_foralls = Bool -> SDoc -> SDoc
ppUnless (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [IfaceBndr]
bndrs) forall a b. (a -> b) -> a -> b
$ SDoc
forAllLit SDoc -> SDoc -> SDoc
<+> [IfaceBndr] -> SDoc
pprIfaceBndrs [IfaceBndr]
bndrs SDoc -> SDoc -> SDoc
<> SDoc
dot
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
text String
"instance" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr OverlapFlag
flag
SDoc -> SDoc -> SDoc
<+> (if IsOrphan -> Bool
isOrphan IsOrphan
orph then String -> SDoc
text String
"[orphan]" else SDoc
Outputable.empty)
SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfExtName
cls SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
brackets (forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas Maybe IfaceTyCon -> SDoc
ppr_rough [Maybe IfaceTyCon]
mb_tcs))
Int
2 (SDoc
equals SDoc -> SDoc -> 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
text String
"family instance"
SDoc -> SDoc -> SDoc
<+> (if IsOrphan -> Bool
isOrphan IsOrphan
orph then String -> SDoc
text String
"[orphan]" else SDoc
Outputable.empty)
SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfExtName
fam SDoc -> SDoc -> SDoc
<+> forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas (SDoc -> SDoc
brackets forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe IfaceTyCon -> SDoc
ppr_rough) [Maybe IfaceTyCon]
mb_tcs)
Int
2 (SDoc
equals SDoc -> SDoc -> 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
dot
ppr_rough (Just IfaceTyCon
tc) = 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
parens
pprIfaceExpr :: (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr :: (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
_ (IfaceLcl IfLclName
v) = forall a. Outputable a => a -> SDoc
ppr IfLclName
v
pprIfaceExpr SDoc -> SDoc
_ (IfaceExt IfExtName
v) = forall a. Outputable a => a -> SDoc
ppr IfExtName
v
pprIfaceExpr SDoc -> SDoc
_ (IfaceLit Literal
l) = forall a. Outputable a => a -> SDoc
ppr Literal
l
pprIfaceExpr SDoc -> SDoc
_ (IfaceFCall ForeignCall
cc IfaceType
ty) = SDoc -> SDoc
braces (forall a. Outputable a => a -> SDoc
ppr ForeignCall
cc SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceType
ty)
pprIfaceExpr SDoc -> SDoc
_ (IfaceType IfaceType
ty) = Char -> SDoc
char Char
'@' SDoc -> SDoc -> SDoc
<> IfaceType -> SDoc
pprParendIfaceType IfaceType
ty
pprIfaceExpr SDoc -> SDoc
_ (IfaceCo IfaceCoercion
co) = String -> SDoc
text String
"@~" SDoc -> SDoc -> SDoc
<> IfaceCoercion -> SDoc
pprParendIfaceCoercion IfaceCoercion
co
pprIfaceExpr SDoc -> SDoc
add_par app :: IfaceExpr
app@(IfaceApp IfaceExpr
_ IfaceExpr
_) = SDoc -> SDoc
add_par (IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp IfaceExpr
app [])
pprIfaceExpr SDoc -> SDoc
_ (IfaceTuple TupleSort
c [IfaceExpr]
as) = TupleSort -> SDoc -> SDoc
tupleParens TupleSort
c (forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas forall a. Outputable a => a -> SDoc
ppr [IfaceExpr]
as)
pprIfaceExpr SDoc -> SDoc
add_par i :: IfaceExpr
i@(IfaceLam IfaceLamBndr
_ IfaceExpr
_)
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
sep [Char -> SDoc
char Char
'\\' SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
sep (forall a b. (a -> b) -> [a] -> [b]
map IfaceLamBndr -> SDoc
pprIfaceLamBndr [IfaceLamBndr]
bndrs) SDoc -> SDoc -> SDoc
<+> 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
bforall a. a -> [a] -> [a]
:[IfaceLamBndr]
bs) IfaceExpr
e
collect [IfaceLamBndr]
bs IfaceExpr
e = (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
sep [ String -> SDoc
text String
"case" SDoc -> SDoc -> SDoc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
scrut
, String -> SDoc
text String
"ret_ty" SDoc -> SDoc -> SDoc
<+> IfaceType -> SDoc
pprParendIfaceType IfaceType
ty
, String -> SDoc
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
sep [String -> SDoc
text String
"case"
SDoc -> SDoc -> SDoc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
scrut SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"of"
SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfLclName
bndr SDoc -> SDoc -> SDoc
<+> Char -> SDoc
char Char
'{' SDoc -> SDoc -> SDoc
<+> IfaceConAlt -> [IfLclName] -> SDoc
ppr_con_bs IfaceConAlt
con [IfLclName]
bs SDoc -> SDoc -> SDoc
<+> SDoc
arrow,
(SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
rhs SDoc -> SDoc -> SDoc
<+> Char -> SDoc
char Char
'}'])
pprIfaceExpr SDoc -> SDoc
add_par (IfaceCase IfaceExpr
scrut IfLclName
bndr [IfaceAlt]
alts)
= SDoc -> SDoc
add_par ([SDoc] -> SDoc
sep [String -> SDoc
text String
"case"
SDoc -> SDoc -> SDoc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
scrut SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"of"
SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfLclName
bndr SDoc -> SDoc -> SDoc
<+> Char -> SDoc
char Char
'{',
Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
sep (forall a b. (a -> b) -> [a] -> [b]
map IfaceAlt -> SDoc
pprIfaceAlt [IfaceAlt]
alts)) SDoc -> SDoc -> SDoc
<+> Char -> SDoc
char Char
'}'])
pprIfaceExpr SDoc -> SDoc
_ (IfaceCast IfaceExpr
expr IfaceCoercion
co)
= [SDoc] -> SDoc
sep [IfaceExpr -> SDoc
pprParendIfaceExpr IfaceExpr
expr,
Int -> SDoc -> SDoc
nest Int
2 (String -> SDoc
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
sep [String -> SDoc
text String
"let {",
Int -> SDoc -> SDoc
nest Int
2 ((IfaceLetBndr, IfaceExpr) -> SDoc
ppr_bind (IfaceLetBndr
b, IfaceExpr
rhs)),
String -> SDoc
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
sep [String -> SDoc
text String
"letrec {",
Int -> SDoc -> SDoc
nest Int
2 ([SDoc] -> SDoc
sep (forall a b. (a -> b) -> [a] -> [b]
map (IfaceLetBndr, IfaceExpr) -> SDoc
ppr_bind [(IfaceLetBndr, IfaceExpr)]
pairs)),
String -> SDoc
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
<+> (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
sep [IfaceConAlt -> [IfLclName] -> SDoc
ppr_con_bs IfaceConAlt
con [IfLclName]
bs, SDoc
arrow SDoc -> SDoc -> SDoc
<+> (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 = forall a. Outputable a => a -> SDoc
ppr IfaceConAlt
con SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
hsep (forall a b. (a -> b) -> [a] -> [b]
map 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 IfaceJoinInfo
ji, IfaceExpr
rhs)
= [SDoc] -> SDoc
sep [SDoc -> Int -> SDoc -> SDoc
hang (forall a. Outputable a => a -> SDoc
ppr IfLclName
b SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceType
ty) Int
2 (forall a. Outputable a => a -> SDoc
ppr IfaceJoinInfo
ji SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceIdInfo
info),
SDoc
equals SDoc -> SDoc -> SDoc
<+> (SDoc -> SDoc) -> IfaceExpr -> SDoc
pprIfaceExpr SDoc -> SDoc
noParens IfaceExpr
rhs]
pprIfaceTickish :: IfaceTickish -> SDoc
pprIfaceTickish :: IfaceTickish -> SDoc
pprIfaceTickish (IfaceHpcTick Module
m Int
ix)
= SDoc -> SDoc
braces (String -> SDoc
text String
"tick" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Module
m SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Int
ix)
pprIfaceTickish (IfaceSCC CostCentre
cc Bool
tick Bool
scope)
= SDoc -> SDoc
braces (CostCentre -> SDoc
pprCostCentreCore CostCentre
cc SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Bool
tick SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Bool
scope)
pprIfaceTickish (IfaceSource RealSrcSpan
src String
_names)
= SDoc -> SDoc
braces (Bool -> RealSrcSpan -> SDoc
pprUserRealSpan Bool
True RealSrcSpan
src)
pprIfaceApp :: IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp :: IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp (IfaceApp IfaceExpr
fun IfaceExpr
arg) [SDoc]
args = IfaceExpr -> [SDoc] -> SDoc
pprIfaceApp IfaceExpr
fun forall a b. (a -> b) -> a -> b
$
Int -> SDoc -> SDoc
nest Int
2 (IfaceExpr -> SDoc
pprParendIfaceExpr IfaceExpr
arg) forall a. a -> [a] -> [a]
: [SDoc]
args
pprIfaceApp IfaceExpr
fun [SDoc]
args = [SDoc] -> SDoc
sep (IfaceExpr -> SDoc
pprParendIfaceExpr IfaceExpr
fun forall a. a -> [a] -> [a]
: [SDoc]
args)
instance Outputable IfaceConAlt where
ppr :: IfaceConAlt -> SDoc
ppr IfaceConAlt
IfaceDefault = String -> SDoc
text String
"DEFAULT"
ppr (IfaceLitAlt Literal
l) = forall a. Outputable a => a -> SDoc
ppr Literal
l
ppr (IfaceDataAlt IfExtName
d) = forall a. Outputable a => a -> SDoc
ppr IfExtName
d
instance Outputable IfaceIdDetails where
ppr :: IfaceIdDetails -> SDoc
ppr IfaceIdDetails
IfVanillaId = SDoc
Outputable.empty
ppr (IfRecSelId Either IfaceTyCon IfaceDecl
tc Bool
b) = String -> SDoc
text String
"RecSel" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Either IfaceTyCon IfaceDecl
tc
SDoc -> SDoc -> SDoc
<+> if Bool
b
then String -> SDoc
text String
"<naughty>"
else SDoc
Outputable.empty
ppr IfaceIdDetails
IfDFunId = String -> SDoc
text String
"DFunId"
instance Outputable IfaceInfoItem where
ppr :: IfaceInfoItem -> SDoc
ppr (HsUnfold Bool
lb IfaceUnfolding
unf) = String -> SDoc
text String
"Unfolding"
SDoc -> SDoc -> SDoc
<> Bool -> SDoc -> SDoc
ppWhen Bool
lb (String -> SDoc
text String
"(loop-breaker)")
SDoc -> SDoc -> SDoc
<> SDoc
colon SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceUnfolding
unf
ppr (HsInline InlinePragma
prag) = String -> SDoc
text String
"Inline:" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr InlinePragma
prag
ppr (HsArity Int
arity) = String -> SDoc
text String
"Arity:" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
int Int
arity
ppr (HsStrictness StrictSig
str) = String -> SDoc
text String
"Strictness:" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr StrictSig
str
ppr (HsCpr CprSig
cpr) = String -> SDoc
text String
"CPR:" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr CprSig
cpr
ppr IfaceInfoItem
HsNoCafRefs = String -> SDoc
text String
"HasNoCafRefs"
ppr IfaceInfoItem
HsLevity = String -> SDoc
text String
"Never levity-polymorphic"
ppr (HsLFInfo IfaceLFInfo
lf_info) = String -> SDoc
text String
"LambdaFormInfo:" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr IfaceLFInfo
lf_info
instance Outputable IfaceJoinInfo where
ppr :: IfaceJoinInfo -> SDoc
ppr IfaceJoinInfo
IfaceNotJoinPoint = SDoc
empty
ppr (IfaceJoinPoint Int
ar) = SDoc -> SDoc
angleBrackets (String -> SDoc
text String
"join" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Int
ar)
instance Outputable IfaceUnfolding where
ppr :: IfaceUnfolding -> SDoc
ppr (IfCompulsory IfaceExpr
e) = String -> SDoc
text String
"<compulsory>" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens (forall a. Outputable a => a -> SDoc
ppr IfaceExpr
e)
ppr (IfCoreUnfold Bool
s IfaceExpr
e) = (if Bool
s
then String -> SDoc
text String
"<stable>"
else SDoc
Outputable.empty)
SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens (forall a. Outputable a => a -> SDoc
ppr IfaceExpr
e)
ppr (IfInlineRule Int
a Bool
uok Bool
bok IfaceExpr
e) = [SDoc] -> SDoc
sep [String -> SDoc
text String
"InlineRule"
SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr (Int
a,Bool
uok,Bool
bok),
IfaceExpr -> SDoc
pprParendIfaceExpr IfaceExpr
e]
ppr (IfDFunUnfold [IfaceBndr]
bs [IfaceExpr]
es) = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"DFun:" SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
sep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [IfaceBndr]
bs) SDoc -> SDoc -> SDoc
<> SDoc
dot)
Int
2 ([SDoc] -> SDoc
sep (forall a b. (a -> b) -> [a] -> [b]
map IfaceExpr -> SDoc
pprParendIfaceExpr [IfaceExpr]
es))
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 })
= 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 })
= 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 })
= 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 })
= 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
&&&
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
&&&
forall b a. b -> (a -> b) -> Maybe a -> b
maybe NameSet
emptyNameSet (IfExtName -> NameSet
unitNameSet forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) Maybe (IfExtName, Bool)
mb_builder NameSet -> NameSet -> NameSet
&&&
forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs [IfaceForAllSpecBndr]
univ_bndrs NameSet -> NameSet -> 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
&&&
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 (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
&&&
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceAT -> NameSet
freeNamesIfAT [IfaceAT]
ats NameSet -> NameSet -> 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 })
= forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceTvBndr -> NameSet
freeNamesIfTvBndr [IfaceTvBndr]
tyvars NameSet -> NameSet -> 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 Bool
_) =
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either IfaceTyCon -> NameSet
freeNamesIfTc IfaceDecl -> NameSet
freeNamesIfDecl Either IfaceTyCon IfaceDecl
tc
freeNamesIfIdDetails IfaceIdDetails
_ = 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
&&& 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 = 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 [IfaceConDecl]
c) = forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceConDecl -> NameSet
freeNamesIfConDecl [IfaceConDecl]
c
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 })
= forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceBndr -> NameSet
freeNamesIfBndr [IfaceBndr]
ex_tvs NameSet -> NameSet -> NameSet
&&&
IfaceContext -> NameSet
freeNamesIfContext IfaceContext
ctxt NameSet -> NameSet -> NameSet
&&&
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(IfaceType, IfaceType)]
arg_tys) NameSet -> NameSet -> NameSet
&&&
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(IfaceType, IfaceType)]
arg_tys) NameSet -> NameSet -> NameSet
&&&
[IfExtName] -> NameSet
mkNameSet (forall a b. (a -> b) -> [a] -> [b]
map FieldLabel -> IfExtName
flSelector [FieldLabel]
flds) NameSet -> NameSet -> NameSet
&&&
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceType -> NameSet
freeNamesIfType (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [IfaceTvBndr]
eq_spec) NameSet -> NameSet -> 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 ArgFlag
_ 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) = forall vis. VarBndr IfaceBndr vis -> NameSet
freeNamesIfVarBndr IfaceForAllBndr
tv NameSet -> NameSet -> NameSet
&&& IfaceType -> NameSet
freeNamesIfType IfaceType
t
freeNamesIfType (IfaceFunTy AnonArgFlag
_ 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
tc [IfaceCoercion]
cos)
= IfaceTyCon -> NameSet
freeNamesIfTc IfaceTyCon
tc NameSet -> NameSet -> NameSet
&&& forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceCoercion -> NameSet
freeNamesIfCoercion [IfaceCoercion]
cos
freeNamesIfCoercion (IfaceAppCo IfaceCoercion
c1 IfaceCoercion
c2)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c1 NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c2
freeNamesIfCoercion (IfaceForAllCo IfaceBndr
_ IfaceCoercion
kind_co IfaceCoercion
co)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
kind_co NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfCoercion (IfaceFreeCoVar TyVar
_) = NameSet
emptyNameSet
freeNamesIfCoercion (IfaceCoVarCo IfLclName
_) = NameSet
emptyNameSet
freeNamesIfCoercion (IfaceHoleCo TyVar
_) = NameSet
emptyNameSet
freeNamesIfCoercion (IfaceAxiomInstCo IfExtName
ax Int
_ [IfaceCoercion]
cos)
= IfExtName -> NameSet
unitNameSet IfExtName
ax NameSet -> NameSet -> NameSet
&&& forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceCoercion -> NameSet
freeNamesIfCoercion [IfaceCoercion]
cos
freeNamesIfCoercion (IfaceUnivCo IfaceUnivCoProv
p Role
_ IfaceType
t1 IfaceType
t2)
= IfaceUnivCoProv -> NameSet
freeNamesIfProv IfaceUnivCoProv
p NameSet -> NameSet -> NameSet
&&& IfaceType -> NameSet
freeNamesIfType IfaceType
t1 NameSet -> NameSet -> NameSet
&&& IfaceType -> NameSet
freeNamesIfType IfaceType
t2
freeNamesIfCoercion (IfaceSymCo IfaceCoercion
c)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c
freeNamesIfCoercion (IfaceTransCo IfaceCoercion
c1 IfaceCoercion
c2)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c1 NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c2
freeNamesIfCoercion (IfaceNthCo Int
_ IfaceCoercion
co)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfCoercion (IfaceLRCo LeftOrRight
_ IfaceCoercion
co)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfCoercion (IfaceInstCo IfaceCoercion
co IfaceCoercion
co2)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co2
freeNamesIfCoercion (IfaceKindCo IfaceCoercion
c)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
c
freeNamesIfCoercion (IfaceSubCo IfaceCoercion
co)
= IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfCoercion (IfaceAxiomRuleCo IfLclName
_ax [IfaceCoercion]
cos)
= forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceCoercion -> NameSet
freeNamesIfCoercion [IfaceCoercion]
cos
freeNamesIfProv :: IfaceUnivCoProv -> NameSet
freeNamesIfProv :: IfaceUnivCoProv -> NameSet
freeNamesIfProv (IfacePhantomProv IfaceCoercion
co) = IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfProv (IfaceProofIrrelProv IfaceCoercion
co) = IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfProv (IfacePluginProv String
_) = NameSet
emptyNameSet
freeNamesIfProv (IfaceCorePrepProv Bool
_) = NameSet
emptyNameSet
freeNamesIfVarBndr :: VarBndr IfaceBndr vis -> NameSet
freeNamesIfVarBndr :: forall vis. VarBndr IfaceBndr vis -> NameSet
freeNamesIfVarBndr (Bndr IfaceBndr
bndr vis
_) = IfaceBndr -> NameSet
freeNamesIfBndr IfaceBndr
bndr
freeNamesIfVarBndrs :: [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs :: forall vis. [VarBndr IfaceBndr vis] -> NameSet
freeNamesIfVarBndrs = forall a. (a -> NameSet) -> [a] -> NameSet
fnList forall vis. VarBndr IfaceBndr vis -> NameSet
freeNamesIfVarBndr
freeNamesIfBndr :: IfaceBndr -> NameSet
freeNamesIfBndr :: IfaceBndr -> NameSet
freeNamesIfBndr (IfaceIdBndr IfaceIdBndr
b) = IfaceIdBndr -> NameSet
freeNamesIfIdBndr IfaceIdBndr
b
freeNamesIfBndr (IfaceTvBndr IfaceTvBndr
b) = IfaceTvBndr -> NameSet
freeNamesIfTvBndr IfaceTvBndr
b
freeNamesIfBndrs :: [IfaceBndr] -> NameSet
freeNamesIfBndrs :: [IfaceBndr] -> NameSet
freeNamesIfBndrs = forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceBndr -> NameSet
freeNamesIfBndr
freeNamesIfLetBndr :: IfaceLetBndr -> NameSet
freeNamesIfLetBndr :: IfaceLetBndr -> NameSet
freeNamesIfLetBndr (IfLetBndr IfLclName
_name IfaceType
ty IfaceIdInfo
info IfaceJoinInfo
_ji) = IfaceType -> NameSet
freeNamesIfType IfaceType
ty
NameSet -> NameSet -> NameSet
&&& IfaceIdInfo -> NameSet
freeNamesIfIdInfo IfaceIdInfo
info
freeNamesIfTvBndr :: IfaceTvBndr -> NameSet
freeNamesIfTvBndr :: IfaceTvBndr -> NameSet
freeNamesIfTvBndr (IfLclName
_fs,IfaceType
k) = IfaceType -> NameSet
freeNamesIfKind IfaceType
k
freeNamesIfIdBndr :: IfaceIdBndr -> NameSet
freeNamesIfIdBndr :: IfaceIdBndr -> NameSet
freeNamesIfIdBndr (IfaceType
_, IfLclName
_fs,IfaceType
k) = IfaceType -> NameSet
freeNamesIfKind IfaceType
k
freeNamesIfIdInfo :: IfaceIdInfo -> NameSet
freeNamesIfIdInfo :: IfaceIdInfo -> NameSet
freeNamesIfIdInfo = forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceInfoItem -> NameSet
freeNamesItem
freeNamesItem :: IfaceInfoItem -> NameSet
freeNamesItem :: IfaceInfoItem -> NameSet
freeNamesItem (HsUnfold Bool
_ IfaceUnfolding
u) = IfaceUnfolding -> NameSet
freeNamesIfUnfold IfaceUnfolding
u
freeNamesItem (HsLFInfo (IfLFCon IfExtName
n)) = IfExtName -> NameSet
unitNameSet IfExtName
n
freeNamesItem IfaceInfoItem
_ = NameSet
emptyNameSet
freeNamesIfUnfold :: IfaceUnfolding -> NameSet
freeNamesIfUnfold :: IfaceUnfolding -> NameSet
freeNamesIfUnfold (IfCoreUnfold Bool
_ IfaceExpr
e) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
e
freeNamesIfUnfold (IfCompulsory IfaceExpr
e) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
e
freeNamesIfUnfold (IfInlineRule Int
_ Bool
_ Bool
_ IfaceExpr
e) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
e
freeNamesIfUnfold (IfDFunUnfold [IfaceBndr]
bs [IfaceExpr]
es) = [IfaceBndr] -> NameSet
freeNamesIfBndrs [IfaceBndr]
bs NameSet -> NameSet -> NameSet
&&& forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceExpr -> NameSet
freeNamesIfExpr [IfaceExpr]
es
freeNamesIfExpr :: IfaceExpr -> NameSet
freeNamesIfExpr :: IfaceExpr -> NameSet
freeNamesIfExpr (IfaceExt IfExtName
v) = IfExtName -> NameSet
unitNameSet IfExtName
v
freeNamesIfExpr (IfaceFCall ForeignCall
_ IfaceType
ty) = IfaceType -> NameSet
freeNamesIfType IfaceType
ty
freeNamesIfExpr (IfaceType IfaceType
ty) = IfaceType -> NameSet
freeNamesIfType IfaceType
ty
freeNamesIfExpr (IfaceCo IfaceCoercion
co) = IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfExpr (IfaceTuple TupleSort
_ [IfaceExpr]
as) = forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceExpr -> NameSet
freeNamesIfExpr [IfaceExpr]
as
freeNamesIfExpr (IfaceLam (IfaceBndr
b,IfaceOneShot
_) IfaceExpr
body) = IfaceBndr -> NameSet
freeNamesIfBndr IfaceBndr
b NameSet -> NameSet -> NameSet
&&& IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
body
freeNamesIfExpr (IfaceApp IfaceExpr
f IfaceExpr
a) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
f NameSet -> NameSet -> NameSet
&&& IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
a
freeNamesIfExpr (IfaceCast IfaceExpr
e IfaceCoercion
co) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
e NameSet -> NameSet -> NameSet
&&& IfaceCoercion -> NameSet
freeNamesIfCoercion IfaceCoercion
co
freeNamesIfExpr (IfaceTick IfaceTickish
_ IfaceExpr
e) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
e
freeNamesIfExpr (IfaceECase IfaceExpr
e IfaceType
ty) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
e NameSet -> NameSet -> NameSet
&&& IfaceType -> NameSet
freeNamesIfType IfaceType
ty
freeNamesIfExpr (IfaceCase IfaceExpr
s IfLclName
_ [IfaceAlt]
alts)
= IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
s NameSet -> NameSet -> NameSet
&&& forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceAlt -> NameSet
fn_alt [IfaceAlt]
alts NameSet -> NameSet -> NameSet
&&& [IfaceAlt] -> NameSet
fn_cons [IfaceAlt]
alts
where
fn_alt :: IfaceAlt -> NameSet
fn_alt (IfaceAlt IfaceConAlt
_con [IfLclName]
_bs IfaceExpr
r) = IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
r
fn_cons :: [IfaceAlt] -> NameSet
fn_cons [] = NameSet
emptyNameSet
fn_cons (IfaceAlt IfaceConAlt
IfaceDefault [IfLclName]
_ IfaceExpr
_ : [IfaceAlt]
xs) = [IfaceAlt] -> NameSet
fn_cons [IfaceAlt]
xs
fn_cons (IfaceAlt (IfaceDataAlt IfExtName
con) [IfLclName]
_ IfaceExpr
_ : [IfaceAlt]
_ ) = IfExtName -> NameSet
unitNameSet IfExtName
con
fn_cons (IfaceAlt
_ : [IfaceAlt]
_ ) = NameSet
emptyNameSet
freeNamesIfExpr (IfaceLet (IfaceNonRec IfaceLetBndr
bndr IfaceExpr
rhs) IfaceExpr
body)
= IfaceLetBndr -> NameSet
freeNamesIfLetBndr IfaceLetBndr
bndr NameSet -> NameSet -> NameSet
&&& IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
rhs NameSet -> NameSet -> NameSet
&&& IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
body
freeNamesIfExpr (IfaceLet (IfaceRec [(IfaceLetBndr, IfaceExpr)]
as) IfaceExpr
x)
= forall a. (a -> NameSet) -> [a] -> NameSet
fnList (IfaceLetBndr, IfaceExpr) -> NameSet
fn_pair [(IfaceLetBndr, IfaceExpr)]
as NameSet -> NameSet -> NameSet
&&& IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
x
where
fn_pair :: (IfaceLetBndr, IfaceExpr) -> NameSet
fn_pair (IfaceLetBndr
bndr, IfaceExpr
rhs) = IfaceLetBndr -> NameSet
freeNamesIfLetBndr IfaceLetBndr
bndr NameSet -> NameSet -> NameSet
&&& IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
rhs
freeNamesIfExpr IfaceExpr
_ = NameSet
emptyNameSet
freeNamesIfTc :: IfaceTyCon -> NameSet
freeNamesIfTc :: IfaceTyCon -> NameSet
freeNamesIfTc IfaceTyCon
tc = IfExtName -> NameSet
unitNameSet (IfaceTyCon -> IfExtName
ifaceTyConName IfaceTyCon
tc)
freeNamesIfRule :: IfaceRule -> NameSet
freeNamesIfRule :: IfaceRule -> NameSet
freeNamesIfRule (IfaceRule { ifRuleBndrs :: IfaceRule -> [IfaceBndr]
ifRuleBndrs = [IfaceBndr]
bs, ifRuleHead :: IfaceRule -> IfExtName
ifRuleHead = IfExtName
f
, ifRuleArgs :: IfaceRule -> [IfaceExpr]
ifRuleArgs = [IfaceExpr]
es, ifRuleRhs :: IfaceRule -> IfaceExpr
ifRuleRhs = IfaceExpr
rhs })
= IfExtName -> NameSet
unitNameSet IfExtName
f NameSet -> NameSet -> NameSet
&&&
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceBndr -> NameSet
freeNamesIfBndr [IfaceBndr]
bs NameSet -> NameSet -> NameSet
&&&
forall a. (a -> NameSet) -> [a] -> NameSet
fnList IfaceExpr -> NameSet
freeNamesIfExpr [IfaceExpr]
es NameSet -> NameSet -> NameSet
&&&
IfaceExpr -> NameSet
freeNamesIfExpr IfaceExpr
rhs
freeNamesIfFamInst :: IfaceFamInst -> NameSet
freeNamesIfFamInst :: IfaceFamInst -> NameSet
freeNamesIfFamInst (IfaceFamInst { ifFamInstFam :: IfaceFamInst -> IfExtName
ifFamInstFam = IfExtName
famName
, ifFamInstAxiom :: IfaceFamInst -> IfExtName
ifFamInstAxiom = IfExtName
axName })
= IfExtName -> NameSet
unitNameSet IfExtName
famName NameSet -> NameSet -> NameSet
&&&
IfExtName -> NameSet
unitNameSet IfExtName
axName
freeNamesIfaceTyConParent :: IfaceTyConParent -> NameSet
freeNamesIfaceTyConParent :: IfaceTyConParent -> NameSet
freeNamesIfaceTyConParent IfaceTyConParent
IfNoParent = NameSet
emptyNameSet
freeNamesIfaceTyConParent (IfDataInstance IfExtName
ax IfaceTyCon
tc IfaceAppArgs
tys)
= IfExtName -> NameSet
unitNameSet IfExtName
ax NameSet -> NameSet -> NameSet
&&& IfaceTyCon -> NameSet
freeNamesIfTc IfaceTyCon
tc NameSet -> NameSet -> NameSet
&&& IfaceAppArgs -> NameSet
freeNamesIfAppArgs IfaceAppArgs
tys
(&&&) :: NameSet -> NameSet -> NameSet
&&& :: NameSet -> NameSet -> NameSet
(&&&) = NameSet -> NameSet -> NameSet
unionNameSet
fnList :: (a -> NameSet) -> [a] -> NameSet
fnList :: forall a. (a -> NameSet) -> [a] -> NameSet
fnList a -> NameSet
f = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr NameSet -> NameSet -> NameSet
(&&&) NameSet
emptyNameSet forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map a -> NameSet
f
instance Binary IfaceDecl where
put_ :: BinHandle -> IfaceDecl -> IO ()
put_ BinHandle
bh (IfaceId IfExtName
name IfaceType
ty IfaceIdDetails
details IfaceIdInfo
idinfo) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
0
BinHandle -> IfExtName -> IO ()
putIfaceTopBndr BinHandle
bh IfExtName
name
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh (IfaceType
ty, IfaceIdDetails
details, IfaceIdInfo
idinfo)
put_ BinHandle
bh (IfaceData IfExtName
a1 [IfaceTyConBinder]
a2 IfaceType
a3 Maybe CType
a4 [Role]
a5 IfaceContext
a6 IfaceConDecls
a7 Bool
a8 IfaceTyConParent
a9) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
2
BinHandle -> IfExtName -> IO ()
putIfaceTopBndr BinHandle
bh IfExtName
a1
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceTyConBinder]
a2
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceType
a3
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Maybe CType
a4
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [Role]
a5
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceContext
a6
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceConDecls
a7
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Bool
a8
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceTyConParent
a9
put_ BinHandle
bh (IfaceSynonym IfExtName
a1 [Role]
a2 [IfaceTyConBinder]
a3 IfaceType
a4 IfaceType
a5) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
3
BinHandle -> IfExtName -> IO ()
putIfaceTopBndr BinHandle
bh IfExtName
a1
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [Role]
a2
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceTyConBinder]
a3
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceType
a4
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceType
a5
put_ BinHandle
bh (IfaceFamily IfExtName
a1 Maybe IfLclName
a2 [IfaceTyConBinder]
a3 IfaceType
a4 IfaceFamTyConFlav
a5 Injectivity
a6) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
4
BinHandle -> IfExtName -> IO ()
putIfaceTopBndr BinHandle
bh IfExtName
a1
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Maybe IfLclName
a2
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceTyConBinder]
a3
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceType
a4
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceFamTyConFlav
a5
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Injectivity
a6
put_ BinHandle
bh (IfaceClass {
ifName :: IfaceDecl -> IfExtName
ifName = IfExtName
a2,
ifRoles :: IfaceDecl -> [Role]
ifRoles = [Role]
a3,
ifBinders :: IfaceDecl -> [IfaceTyConBinder]
ifBinders = [IfaceTyConBinder]
a4,
ifFDs :: IfaceDecl -> [FunDep IfLclName]
ifFDs = [FunDep IfLclName]
a5,
ifBody :: IfaceDecl -> IfaceClassBody
ifBody = IfConcreteClass {
ifClassCtxt :: IfaceClassBody -> IfaceContext
ifClassCtxt = IfaceContext
a1,
ifATs :: IfaceClassBody -> [IfaceAT]
ifATs = [IfaceAT]
a6,
ifSigs :: IfaceClassBody -> [IfaceClassOp]
ifSigs = [IfaceClassOp]
a7,
ifMinDef :: IfaceClassBody -> BooleanFormula IfLclName
ifMinDef = BooleanFormula IfLclName
a8
}}) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
5
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceContext
a1
BinHandle -> IfExtName -> IO ()
putIfaceTopBndr BinHandle
bh IfExtName
a2
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [Role]
a3
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceTyConBinder]
a4
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [FunDep IfLclName]
a5
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceAT]
a6
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceClassOp]
a7
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh BooleanFormula IfLclName
a8
put_ BinHandle
bh (IfaceAxiom IfExtName
a1 IfaceTyCon
a2 Role
a3 [IfaceAxBranch]
a4) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
6
BinHandle -> IfExtName -> IO ()
putIfaceTopBndr BinHandle