+-- When printing any Id binder in debug mode, we print its inline pragma and one-shot-ness
+pprIdBndr id = ppr id <+> ifPprDebug (ppr (getInlinePragma id) <+> ppr (getIdOccInfo id) <+>
+ ppr (getIdDemandInfo id)) <+> ppr (lbvarInfo (idInfo id))
+\end{code}
+
+
+\begin{code}
+ppIdInfo :: IdInfo -> SDoc
+ppIdInfo info
+ = hsep [
+ ppFlavourInfo (flavourInfo info),
+ ppArityInfo a,
+ ppUpdateInfo u,
+ ppWorkerInfo (workerInfo info),
+ ppStrictnessInfo s,
+ ppr d,
+ ppCafInfo c,
+ ppCprInfo m,
+ ppr (lbvarInfo info),
+ pprIfaceCoreRules p
+ -- Inline pragma printed out with all binders; see PprCore.pprIdBndr
+ ]
+ where
+ a = arityInfo info
+ d = demandInfo 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