2 % (c) The AQUA Project, Glasgow University, 1994-1996
4 \section[CoreUnfold]{Core-syntax unfoldings}
6 Unfoldings (which can travel across module boundaries) are in Core
7 syntax (namely @CoreExpr@s).
9 The type @UnfoldingDetails@ sits ``above'' simply-Core-expressions
10 unfoldings, capturing ``higher-level'' things we know about a binding,
11 usually things that the simplifier found out (e.g., ``it's a
12 literal''). In the corner of a @GenForm@ unfolding, you will
13 find, unsurprisingly, a Core expression.
16 #include "HsVersions.h"
19 UnfoldingDetails(..), UnfoldingGuidance(..), -- types
23 mkGenForm, mkLitForm, mkConForm,
26 calcUnfoldingGuidance,
31 IMPORT_DELOOPER(IdLoop) -- for paranoia checking;
32 -- and also to get mkMagicUnfoldingFun
33 IMPORT_DELOOPER(PrelLoop) -- for paranoia checking
35 import Bag ( emptyBag, unitBag, unionBags, Bag )
36 import BinderInfo ( oneTextualOcc, oneSafeOcc )
37 import CgCompInfo ( uNFOLDING_CHEAP_OP_COST,
38 uNFOLDING_DEAR_OP_COST,
39 uNFOLDING_NOREP_LIT_COST
42 import CoreUtils ( coreExprType, manifestlyWHNF )
43 import CostCentre ( ccMentionsId )
44 import Id ( SYN_IE(IdSet), GenId{-instances-} )
45 import IdInfo ( bottomIsGuaranteed )
46 import Literal ( isNoRepLit, isLitLitLit )
48 import PrimOp ( primOpCanTriggerGC, PrimOp(..) )
49 import TyCon ( tyConFamilySize )
50 import Type ( getAppDataTyConExpandingDicts )
51 import UniqSet ( emptyUniqSet, unitUniqSet, mkUniqSet,
52 addOneToUniqSet, unionUniqSets
54 import Usage ( SYN_IE(UVar) )
55 import Util ( isIn, panic )
57 whatsMentionedInId = panic "whatsMentionedInId (CoreUnfold)"
58 getMentionedTyConsAndClassesFromType = panic "getMentionedTyConsAndClassesFromType (CoreUnfold)"
61 %************************************************************************
63 \subsection{@UnfoldingDetails@ and @UnfoldingGuidance@ types}
65 %************************************************************************
67 (And @FormSummary@, too.)
74 [Literal] -- It is a literal, but definitely not one of these
77 [Id] -- It definitely isn't one of these constructors
78 -- This captures the situation in the default branch of
83 -- Then in default-rhs we know that v isn't c1 or c2.
85 -- NB. In the degenerate: case x of {v -> default-rhs}
88 -- which captures the idea that x is eval'd but we don't
89 -- know which constructor.
93 FormSummary -- Tells whether the template is a WHNF or bottom
94 TemplateOutExpr -- The template
95 UnfoldingGuidance -- Tells about the *size* of the template.
98 Unique -- of the Id whose magic unfolding this is
101 type TemplateOutExpr = GenCoreExpr (Id, BinderInfo) Id TyVar UVar
102 -- An OutExpr with occurrence info attached. This is used as
103 -- a template in GeneralForms.
105 mkMagicUnfolding :: Unique -> UnfoldingDetails
106 mkMagicUnfolding tag = MagicForm tag (mkMagicUnfoldingFun tag)
109 = WhnfForm -- Expression is WHNF
110 | BottomForm -- Expression is guaranteed to be bottom. We're more gung
111 -- ho about inlining such things, because it can't waste work
112 | OtherForm -- Anything else
114 instance Outputable FormSummary where
115 ppr sty WhnfForm = ppStr "WHNF"
116 ppr sty BottomForm = ppStr "Bot"
117 ppr sty OtherForm = ppStr "Other"
119 --???mkFormSummary :: StrictnessInfo -> GenCoreExpr bndr Id -> FormSummary
120 mkFormSummary si expr
121 | manifestlyWHNF expr = WhnfForm
122 | bottomIsGuaranteed si = BottomForm
124 -- Chances are that the Id will be decorated with strictness info
125 -- telling that the RHS is definitely bottom. This *might* not be the
126 -- case, if it's been a while since strictness analysis, but leaving out
127 -- the test for manifestlyBottom makes things a little more efficient.
128 -- We can always put it back...
129 -- | manifestlyBottom expr = BottomForm
131 | otherwise = OtherForm
133 whnfDetails :: UnfoldingDetails -> Bool -- True => thing is evaluated
134 whnfDetails (GenForm WhnfForm _ _) = True
135 whnfDetails (OtherLitForm _) = True
136 whnfDetails (OtherConForm _) = True
137 whnfDetails other = False
141 data UnfoldingGuidance
142 = UnfoldNever -- Don't do it!
144 | UnfoldAlways -- There is no "original" definition,
145 -- so you'd better unfold. Or: something
146 -- so cheap to unfold (e.g., 1#) that
147 -- you should do it absolutely always.
149 | EssentialUnfolding -- Like UnfoldAlways, but you *must* do
150 -- it absolutely always.
151 -- This is what we use for data constructors
152 -- and PrimOps, because we don't feel like
153 -- generating curried versions "just in case".
155 | UnfoldIfGoodArgs Int -- if "m" type args and "n" value args; and
156 Int -- those val args are manifestly data constructors
157 [Bool] -- the val-arg positions marked True
158 -- (i.e., a simplification will definitely
160 Int -- The "size" of the unfolding; to be elaborated
163 | BadUnfolding -- This is used by TcPragmas if the *lazy*
164 -- lintUnfolding test fails
165 -- It will never escape from the IdInfo as
166 -- it is caught by getInfo_UF and converted
167 -- to NoUnfoldingDetails
171 instance Outputable UnfoldingGuidance where
172 ppr sty UnfoldNever = ppStr "_N_"
173 ppr sty UnfoldAlways = ppStr "_ALWAYS_"
174 ppr sty EssentialUnfolding = ppStr "_ESSENTIAL_" -- shouldn't appear in an iface
175 ppr sty (UnfoldIfGoodArgs t v cs size)
176 = ppCat [ppStr "_IF_ARGS_", ppInt t, ppInt v,
177 if null cs -- always print *something*
179 else ppBesides (map pp_c cs),
182 pp_c False = ppChar 'X'
183 pp_c True = ppChar 'C'
187 %************************************************************************
189 \subsection{@mkGenForm@ and friends}
191 %************************************************************************
194 mkGenForm :: FormSummary
195 -> TemplateOutExpr -- Template
196 -> UnfoldingGuidance -- Tells about the *size* of the template.
201 -- two shorthand variants:
202 mkLitForm lit = mk_go_for_it (Lit lit)
203 mkConForm con args = mk_go_for_it (Con con args)
205 mk_go_for_it expr = mkGenForm WhnfForm expr UnfoldAlways
208 %************************************************************************
210 \subsection[calcUnfoldingGuidance]{Calculate ``unfolding guidance'' for an expression}
212 %************************************************************************
215 calcUnfoldingGuidance
216 :: Bool -- True <=> OK if _scc_s appear in expr
217 -> Int -- bomb out if size gets bigger than this
218 -> CoreExpr -- expression to look at
221 calcUnfoldingGuidance scc_s_OK bOMB_OUT_SIZE expr
223 (use_binders, ty_binders, val_binders, body) = collectBinders expr
225 case (sizeExpr scc_s_OK bOMB_OUT_SIZE val_binders body) of
227 Nothing -> UnfoldNever
229 Just (size, cased_args)
231 uf = UnfoldIfGoodArgs
234 [ b `is_elem` cased_args | b <- val_binders ]
237 -- pprTrace "calcUnfold:" (ppAbove (ppr PprDebug uf) (ppr PprDebug expr))
240 is_elem = isIn "calcUnfoldingGuidance"
244 sizeExpr :: Bool -- True <=> _scc_s OK
245 -> Int -- Bomb out if it gets bigger than this
246 -> [Id] -- Arguments; we're interested in which of these
249 -> Maybe (Int, -- Size
250 [Id] -- Subset of args which are cased
253 sizeExpr scc_s_OK bOMB_OUT_SIZE args expr
256 size_up (Var v) = sizeOne
257 size_up (App fun arg) = size_up fun `addSize` size_up_arg arg
258 size_up (Lit lit) = if isNoRepLit lit
259 then sizeN uNFOLDING_NOREP_LIT_COST
262 size_up (SCC _ (Con _ _)) = Nothing -- **** HACK *****
263 size_up (SCC lbl body)
264 = if scc_s_OK then size_up body else Nothing
266 size_up (Coerce _ _ body) = size_up body -- Coercions cost nothing
268 size_up (Con con args) = -- 1 + # of val args
269 sizeN (1 + numValArgs args)
270 size_up (Prim op args) = sizeN op_cost -- NB: no charge for PrimOp args
272 op_cost = if primOpCanTriggerGC op
273 then uNFOLDING_DEAR_OP_COST
274 -- these *tend* to be more expensive;
275 -- number chosen to avoid unfolding (HACK)
276 else uNFOLDING_CHEAP_OP_COST
278 size_up expr@(Lam _ _)
280 (uvars, tyvars, args, body) = collectBinders expr
282 size_up body `addSizeN` length args
284 size_up (Let (NonRec binder rhs) body)
291 size_up (Let (Rec pairs) body)
292 = foldr addSize sizeZero [size_up rhs | (_,rhs) <- pairs]
298 size_up (Case scrut alts)
299 = size_up_scrut scrut
301 size_up_alts (coreExprType scrut) alts
302 -- We charge for the "case" itself in "size_up_alts"
305 size_up_arg arg = if isValArg arg then sizeOne else sizeZero{-it's free-}
308 size_up_alts scrut_ty (AlgAlts alts deflt)
309 = foldr (addSize . size_alg_alt) (size_up_deflt deflt) alts
310 `addSizeN` (tyConFamilySize tycon)
311 -- NB: we charge N for an alg. "case", where N is
312 -- the number of constructors in the thing being eval'd.
313 -- (You'll eventually get a "discount" of N if you
314 -- think the "case" is likely to go away.)
316 size_alg_alt (con,args,rhs) = size_up rhs
317 -- Don't charge for args, so that wrappers look cheap
319 (tycon, _, _) = --trace "CoreUnfold.getAppDataTyConExpandingDicts" $
320 getAppDataTyConExpandingDicts scrut_ty
322 size_up_alts _ (PrimAlts alts deflt)
323 = foldr (addSize . size_prim_alt) (size_up_deflt deflt) alts
324 -- *no charge* for a primitive "case"!
326 size_prim_alt (lit,rhs) = size_up rhs
329 size_up_deflt NoDefault = sizeZero
330 size_up_deflt (BindDefault binder rhs) = size_up rhs
333 -- Scrutinees. There are two things going on here.
334 -- First, we want to record if we're case'ing an argument
335 -- Second, we want to charge nothing for the srutinee if it's just
336 -- a variable. That way wrapper-like things look cheap.
337 size_up_scrut (Var v) | v `is_elem` args = Just (0, [v])
338 | otherwise = Just (0, [])
339 size_up_scrut other = size_up other
341 is_elem :: Id -> [Id] -> Bool
342 is_elem = isIn "size_up_scrut"
345 sizeZero = Just (0, [])
346 sizeOne = Just (1, [])
347 sizeN n = Just (n, [])
348 sizeVar v = Just (0, [v])
350 addSizeN Nothing _ = Nothing
351 addSizeN (Just (n, xs)) m
352 | tot < bOMB_OUT_SIZE = Just (tot, xs)
353 | otherwise = Nothing
357 addSize Nothing _ = Nothing
358 addSize _ Nothing = Nothing
359 addSize (Just (n, xs)) (Just (m, ys))
360 | tot < bOMB_OUT_SIZE = Just (tot, xys)
361 | otherwise = Nothing
367 %************************************************************************
369 \subsection[unfoldings-for-ifaces]{Processing unfoldings for interfaces}
371 %************************************************************************
373 Of course, the main thing we do to unfoldings-for-interfaces is {\em
374 print} them. But, while we're at it, we collect info about
375 ``mentioned'' Ids, etc., etc.---we're going to need this stuff anyway.
377 %************************************************************************
379 \subsubsection{Monad stuff for the unfolding-generation game}
381 %************************************************************************
384 type UnfoldM bndr thing
385 = IdSet -- in-scope Ids (passed downwards only)
386 -> (bndr -> Id) -- to extract an Id from a binder (down only)
388 -> (Bag Id, -- mentioned global vars (ditto)
389 Bag TyCon, -- ditto, tycons
390 Bag Class, -- ditto, classes
391 Bool) -- True <=> mentions something litlit-ish
393 -> (thing, (Bag Id, Bag TyCon, Bag Class, Bool)) -- accumulated...
396 A little stuff for in-scopery:
398 no_in_scopes :: IdSet
399 add1 :: IdSet -> Id -> IdSet
400 add_some :: IdSet -> [Id] -> IdSet
402 no_in_scopes = emptyUniqSet
403 in_scopes `add1` x = addOneToUniqSet in_scopes x
404 in_scopes `add_some` xs = in_scopes `unionUniqSets` mkUniqSet xs
407 The can-see-inside-monad functions are the usual sorts of things.
410 thenUf :: UnfoldM bndr a -> (a -> UnfoldM bndr b) -> UnfoldM bndr b
411 thenUf m k in_scopes get_id mentioneds
412 = case m in_scopes get_id mentioneds of { (v, mentioneds1) ->
413 k v in_scopes get_id mentioneds1 }
415 thenUf_ :: UnfoldM bndr a -> UnfoldM bndr b -> UnfoldM bndr b
416 thenUf_ m k in_scopes get_id mentioneds
417 = case m in_scopes get_id mentioneds of { (_, mentioneds1) ->
418 k in_scopes get_id mentioneds1 }
420 mapUf :: (a -> UnfoldM bndr b) -> [a] -> UnfoldM bndr [b]
421 mapUf f [] = returnUf []
423 = f x `thenUf` \ r ->
424 mapUf f xs `thenUf` \ rs ->
427 returnUf :: a -> UnfoldM bndr a
428 returnUf v in_scopes get_id mentioneds = (v, mentioneds)
430 addInScopesUf :: [Id] -> UnfoldM bndr a -> UnfoldM bndr a
431 addInScopesUf more_in_scopes m in_scopes get_id mentioneds
432 = m (in_scopes `add_some` more_in_scopes) get_id mentioneds
434 getInScopesUf :: UnfoldM bndr IdSet
435 getInScopesUf in_scopes get_id mentioneds = (in_scopes, mentioneds)
437 extractIdsUf :: [bndr] -> UnfoldM bndr [Id]
438 extractIdsUf binders in_scopes get_id mentioneds
439 = (map get_id binders, mentioneds)
441 consider_Id :: Id -> UnfoldM bndr ()
442 consider_Id var in_scopes get_id (ids, tcs, clss, has_litlit)
444 (ids2, tcs2, clss2) = whatsMentionedInId in_scopes var
446 ((), (ids `unionBags` ids2,
447 tcs `unionBags` tcs2,
448 clss `unionBags`clss2,
453 addToMentionedIdsUf :: Id -> UnfoldM bndr ()
454 addToMentionedTyConsUf :: Bag TyCon -> UnfoldM bndr ()
455 addToMentionedClassesUf :: Bag Class -> UnfoldM bndr ()
456 litlit_oops :: UnfoldM bndr ()
458 addToMentionedIdsUf add_me in_scopes get_id (ids, tcs, clss, has_litlit)
459 = ((), (ids `unionBags` unitBag add_me, tcs, clss, has_litlit))
461 addToMentionedTyConsUf add_mes in_scopes get_id (ids, tcs, clss, has_litlit)
462 = ((), (ids, tcs `unionBags` add_mes, clss, has_litlit))
464 addToMentionedClassesUf add_mes in_scopes get_id (ids, tcs, clss, has_litlit)
465 = ((), (ids, tcs, clss `unionBags` add_mes, has_litlit))
467 litlit_oops in_scopes get_id (ids, tcs, clss, _)
468 = ((), (ids, tcs, clss, True))
472 %************************************************************************
474 \subsubsection{Gathering up info for an interface-unfolding}
476 %************************************************************************
481 :: (bndr -> Id) -- so we can get Ids out of binders
482 -> GenCoreExpr bndr Id -- input expression
483 -> (Bag Id, Bag TyCon, Bag Class,
484 -- what we found mentioned in the expr
485 Bool -- True <=> mentions a ``litlit''-ish thing
486 -- (the guy on the other side of an interface
487 -- may not be able to handle it)
491 mentionedInUnfolding get_id expr
492 = case (ment_expr expr no_in_scopes get_id (emptyBag, emptyBag, emptyBag, False)) of
493 (_, (ids_bag, tcs_bag, clss_bag, has_litlit)) ->
494 (ids_bag, tcs_bag, clss_bag, has_litlit)
498 --ment_expr :: GenCoreExpr bndr Id -> UnfoldM bndr ()
500 ment_expr (Var v) = consider_Id v
501 ment_expr (Lit l) = consider_lit l
503 ment_expr expr@(Lam _ _)
505 (uvars, tyvars, args, body) = collectBinders expr
507 extractIdsUf args `thenUf` \ bs_ids ->
508 addInScopesUf bs_ids (
509 -- this considering is just to extract any mentioned types/classes
510 mapUf consider_Id bs_ids `thenUf_`
514 ment_expr (App fun arg)
515 = ment_expr fun `thenUf_`
519 = consider_Id c `thenUf_`
520 mapUf ment_arg as `thenUf_`
523 ment_expr (Prim op as)
524 = ment_op op `thenUf_`
525 mapUf ment_arg as `thenUf_`
528 ment_op (CCallOp str is_asm may_gc arg_tys res_ty)
529 = mapUf ment_ty arg_tys `thenUf_`
531 ment_op other_op = returnUf ()
533 ment_expr (Case scrutinee alts)
534 = ment_expr scrutinee `thenUf_`
537 ment_expr (Let (NonRec bind rhs) body)
538 = ment_expr rhs `thenUf_`
539 extractIdsUf [bind] `thenUf` \ bi@[bind_id] ->
541 ment_expr body `thenUf_`
542 consider_Id bind_id )
544 ment_expr (Let (Rec pairs) body)
546 binders = map fst pairs
549 extractIdsUf binders `thenUf` \ binder_ids ->
550 addInScopesUf binder_ids (
551 mapUf ment_expr rhss `thenUf_`
552 mapUf consider_Id binder_ids `thenUf_`
555 ment_expr (SCC cc expr)
556 = (case (ccMentionsId cc) of
557 Just id -> consider_Id id
558 Nothing -> returnUf ()
560 `thenUf_` ment_expr expr
562 ment_expr (Coerce _ _ _) = panic "ment_expr:Coerce"
567 (tycons, clss) = getMentionedTyConsAndClassesFromType ty
569 addToMentionedTyConsUf tycons `thenUf_`
570 addToMentionedClassesUf clss
574 ment_alts alg_alts@(AlgAlts alts deflt)
575 = mapUf ment_alt alts `thenUf_`
578 ment_alt alt@(con, params, rhs)
579 = consider_Id con `thenUf_`
580 extractIdsUf params `thenUf` \ param_ids ->
581 addInScopesUf param_ids (
582 -- "consider" them so we can chk out their types...
583 mapUf consider_Id param_ids `thenUf_`
586 ment_alts (PrimAlts alts deflt)
587 = mapUf ment_alt alts `thenUf_`
590 ment_alt alt@(lit, rhs) = ment_expr rhs
596 ment_deflt d@(BindDefault b rhs)
597 = extractIdsUf [b] `thenUf` \ bi@[b_id] ->
599 consider_Id b_id `thenUf_`
603 ment_arg (VarArg v) = consider_Id v
604 ment_arg (LitArg l) = consider_lit l
605 ment_arg (TyArg ty) = ment_ty ty
606 ment_arg (UsageArg _) = returnUf ()
610 | isLitLitLit lit = litlit_oops `thenUf_` returnUf ()
611 | otherwise = returnUf ()
614 %************************************************************************
616 \subsubsection{Printing unfoldings in interfaces}
618 %************************************************************************
620 Printing Core-expression unfoldings is sufficiently delicate that we
621 give it its own function.
628 pprCoreUnfolding expr
630 (_, renamed) = instCoreExpr uniqSupply_u expr
631 -- We rename every unfolding with a "steady" unique supply,
632 -- so that the names won't constantly change.
633 -- One place we *MUST NOT* use a splittable UniqueSupply!
635 ppr_uf_Expr emptyUniqSet renamed
637 ppr_Unfolding = PprUnfolding (panic "CoreUnfold:ppr_Unfolding")
641 ppr_uf_Expr in_scopes (Var v) = pprIdInUnfolding in_scopes v
642 ppr_uf_Expr in_scopes (Lit l) = ppr ppr_Unfolding l
644 ppr_uf_Expr in_scopes (Con c as)
645 = ppBesides [ppPStr SLIT("_!_ "), pprIdInUnfolding no_in_scopes c, ppSP,
646 ppLbrack, ppIntersperse pp'SP{-'-} (map (pprParendUniType ppr_Unfolding) ts), ppRbrack,
647 ppSP, ppLbrack, ppIntersperse pp'SP{-'-} (map (ppr_uf_Atom in_scopes) as), ppRbrack]
648 ppr_uf_Expr in_scopes (Prim op as)
649 = ppBesides [ppPStr SLIT("_#_ "), ppr ppr_Unfolding op, ppSP,
650 ppLbrack, ppIntersperse pp'SP{-'-} (map (pprParendUniType ppr_Unfolding) ts), ppRbrack,
651 ppSP, ppLbrack, ppIntersperse pp'SP{-'-} (map (ppr_uf_Atom in_scopes) as), ppRbrack]
653 ppr_uf_Expr in_scopes (Lam binder body)
654 = ppCat [ppChar '\\', ppr_uf_Binder binder,
655 ppPStr SLIT("->"), ppr_uf_Expr (in_scopes `add1` binder) body]
657 ppr_uf_Expr in_scopes (CoTyLam tyvar expr)
658 = ppCat [ppPStr SLIT("_/\\_"), interppSP ppr_Unfolding (tyvar:tyvars), ppStr "->",
659 ppr_uf_Expr in_scopes body]
661 (tyvars, body) = collect_tyvars expr
663 collect_tyvars (CoTyLam tyv e) = ( tyv:tyvs, e_after )
664 where (tyvs, e_after) = collect_tyvars e
665 collect_tyvars other_e = ( [], other_e )
667 ppr_uf_Expr in_scopes expr@(App fun_expr atom)
669 (fun, args) = collect_args expr []
671 ppCat [ppPStr SLIT("_APP_ "), ppr_uf_Expr in_scopes fun, ppLbrack,
672 ppIntersperse pp'SP{-'-} (map (ppr_uf_Atom in_scopes) args), ppRbrack]
674 collect_args (App fun arg) args = collect_args fun (arg:args)
675 collect_args fun args = (fun, args)
677 ppr_uf_Expr in_scopes (CoTyApp expr ty)
678 = ppCat [ppPStr SLIT("_TYAPP_ "), ppr_uf_Expr in_scopes expr,
679 ppChar '{', pprParendUniType ppr_Unfolding ty, ppChar '}']
681 ppr_uf_Expr in_scopes (Case scrutinee alts)
682 = ppCat [ppPStr SLIT("case"), ppr_uf_Expr in_scopes scrutinee, ppStr "of {",
683 pp_alts alts, ppChar '}']
685 pp_alts (AlgAlts alts deflt)
686 = ppCat [ppPStr SLIT("_ALG_"), ppCat (map pp_alg alts), pp_deflt deflt]
687 pp_alts (PrimAlts alts deflt)
688 = ppCat [ppPStr SLIT("_PRIM_"), ppCat (map pp_prim alts), pp_deflt deflt]
690 pp_alg (con, params, rhs)
691 = ppBesides [pprIdInUnfolding no_in_scopes con, ppSP,
692 ppIntersperse ppSP (map ppr_uf_Binder params),
693 ppPStr SLIT(" -> "), ppr_uf_Expr (in_scopes `add_some` params) rhs, ppSemi]
696 = ppBesides [ppr ppr_Unfolding lit,
697 ppPStr SLIT(" -> "), ppr_uf_Expr in_scopes rhs, ppSemi]
699 pp_deflt NoDefault = ppPStr SLIT("_NO_DEFLT_")
700 pp_deflt (BindDefault binder rhs)
701 = ppBesides [ppr_uf_Binder binder, ppPStr SLIT(" -> "),
702 ppr_uf_Expr (in_scopes `add1` binder) rhs]
704 ppr_uf_Expr in_scopes (Let (NonRec binder rhs) body)
705 = ppBesides [ppStr "let {", ppr_uf_Binder binder, ppPStr SLIT(" = "), ppr_uf_Expr in_scopes rhs,
706 ppStr "} in ", ppr_uf_Expr (in_scopes `add1` binder) body]
708 ppr_uf_Expr in_scopes (Let (Rec pairs) body)
709 = ppBesides [ppStr "_LETREC_ {", ppIntersperse sep (map pp_pair pairs),
710 ppStr "} in ", ppr_uf_Expr new_in_scopes body]
712 sep = ppBeside ppSemi ppSP
713 new_in_scopes = in_scopes `add_some` map fst pairs
715 pp_pair (b, rhs) = ppCat [ppr_uf_Binder b, ppEquals, ppr_uf_Expr new_in_scopes rhs]
717 ppr_uf_Expr in_scopes (SCC cc body)
718 = ASSERT(not (noCostCentreAttached cc))
719 ASSERT(not (currentOrSubsumedCosts cc))
720 ppBesides [ppStr "_scc_ { ", ppStr (showCostCentre ppr_Unfolding False{-not as string-} cc), ppStr " } ", ppr_uf_Expr in_scopes body]
722 ppr_uf_Expr in_scopes (Coerce _ _ _) = panic "ppr_uf_Expr:Coerce"
726 ppr_uf_Binder :: Id -> Pretty
728 = ppBesides [ppLparen, pprIdInUnfolding (unitUniqSet v) v, ppPStr SLIT(" :: "),
729 ppr ppr_Unfolding (idType v), ppRparen]
731 ppr_uf_Atom in_scopes (LitArg l) = ppr ppr_Unfolding l
732 ppr_uf_Atom in_scopes (VarArg v) = pprIdInUnfolding in_scopes v