+-- When printing any Id binder in debug mode, we print its inline pragma and one-shot-ness
+pprIdBndr id = ppr id <+>
+ (megaSeqIdInfo (idInfo id) `seq`
+ -- Useful for poking on black holes
+ ifPprDebug (ppr (idInlinePragma id) <+> ppr (idOccInfo id) <+>
+ ppr (idDemandInfo id)) <+> ppr (idLBVarInfo id))
+\end{code}
+
+
+\begin{code}
+ppIdInfo :: IdInfo -> SDoc
+ppIdInfo info
+ = hsep [
+ ppFlavourInfo (flavourInfo info),
+ ppArityInfo a,
+ ppUpdateInfo u,
+ ppWorkerInfo (workerInfo info),
+ ppStrictnessInfo s,
+ ppCafInfo c,
+ ppCprInfo m,
+ pprIfaceCoreRules p
+ -- Inline pragma, occ, demand, lbvar info
+ -- printed out with all binders (when debug is on);
+ -- see PprCore.pprIdBndr
+ ]
+ where
+ a = arityInfo info
+ s = strictnessInfo info
+ u = updateInfo info
+ c = cafInfo info
+ m = cprInfo info
+ p = specInfo info
+\end{code}
+
+
+\begin{code}
+pprCoreRules :: Id -> CoreRules -> SDoc
+pprCoreRules var (Rules rules _) = vcat (map (pprCoreRule (Just var)) rules)
+
+pprIfaceCoreRules :: CoreRules -> SDoc
+pprIfaceCoreRules (Rules rules _) = vcat (map (pprCoreRule Nothing) rules)
+
+pprCoreRule :: Maybe Id -> CoreRule -> SDoc
+pprCoreRule maybe_fn (BuiltinRule _)
+ = ifPprDebug (ptext SLIT("A built in rule"))
+
+pprCoreRule maybe_fn (Rule name tpl_vars tpl_args rhs)
+ = doubleQuotes (ptext name) <+>
+ sep [
+ ptext SLIT("__forall") <+> braces (sep (map pprTypedBinder tpl_vars)),
+ nest 4 (pp_fn <+> sep (map pprIfaceArg tpl_args)),
+ nest 4 (ptext SLIT("=") <+> pprIfaceUnfolding rhs)
+ ] <+> semi
+ where
+ pp_fn = case maybe_fn of
+ Just id -> ppr id
+ Nothing -> empty -- Interface file