+
+showAttributes :: [(Bool,SDoc)] -> SDoc
+showAttributes stuff
+ | null docs = empty
+ | otherwise = brackets (sep (punctuate comma docs))
+ where
+ docs = [d | (True,d) <- stuff]
+\end{code}
+
+-----------------------------------------------------
+-- Unfolding and UnfoldingGuidance
+-----------------------------------------------------
+
+\begin{code}
+instance Outputable UnfoldingGuidance where
+ ppr UnfNever = ptext (sLit "NEVER")
+ ppr (UnfWhen unsat_ok boring_ok)
+ = ptext (sLit "ALWAYS_IF") <>
+ parens (ptext (sLit "unsat_ok=") <> ppr unsat_ok <> comma <>
+ ptext (sLit "boring_ok=") <> ppr boring_ok)
+ ppr (UnfIfGoodArgs { ug_args = cs, ug_size = size, ug_res = discount })
+ = hsep [ ptext (sLit "IF_ARGS"),
+ brackets (hsep (map int cs)),
+ int size,
+ int discount ]
+
+instance Outputable UnfoldingSource where
+ ppr InlineCompulsory = ptext (sLit "Compulsory")
+ ppr (InlineWrapper w) = ptext (sLit "Worker=") <> ppr w
+ ppr InlineStable = ptext (sLit "InlineStable")
+ ppr InlineRhs = ptext (sLit "<vanilla>")
+
+instance Outputable Unfolding where
+ ppr NoUnfolding = ptext (sLit "No unfolding")
+ ppr (OtherCon cs) = ptext (sLit "OtherCon") <+> ppr cs
+ ppr (DFunUnfolding ar con ops) = ptext (sLit "DFun") <> parens (ptext (sLit "arity=") <> int ar)
+ <+> ppr con <+> brackets (pprWithCommas ppr ops)
+ ppr (CoreUnfolding { uf_src = src
+ , uf_tmpl=rhs, uf_is_top=top, uf_is_value=hnf
+ , uf_is_conlike=conlike, uf_is_cheap=cheap
+ , uf_expandable=exp, uf_guidance=g, uf_arity=arity})
+ = ptext (sLit "Unf") <> braces (pp_info $$ pp_rhs)
+ where
+ pp_info = fsep $ punctuate comma
+ [ ptext (sLit "Src=") <> ppr src
+ , ptext (sLit "TopLvl=") <> ppr top
+ , ptext (sLit "Arity=") <> int arity
+ , ptext (sLit "Value=") <> ppr hnf
+ , ptext (sLit "ConLike=") <> ppr conlike
+ , ptext (sLit "Cheap=") <> ppr cheap
+ , ptext (sLit "Expandable=") <> ppr exp
+ , ptext (sLit "Guidance=") <> ppr g ]
+ pp_tmpl = ptext (sLit "Tmpl=") <+> ppr rhs
+ pp_rhs | isStableSource src = pp_tmpl
+ | otherwise = empty
+ -- Don't print the RHS or we get a quadratic
+ -- blowup in the size of the printout!
+
+instance Outputable e => Outputable (DFunArg e) where
+ ppr (DFunPolyArg e) = braces (ppr e)
+ ppr (DFunConstArg e) = ppr e
+ ppr (DFunLamArg i) = char '<' <> int i <> char '>'