X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreSyn.lhs;h=ac32bc201b4051e7b7036b40069ac0e2b5ced7cc;hb=08409937537b9d4d8937e1d7264f6b238d350ccd;hp=86a7e9d8cbf235e9fcb3daff80f20400e320cdf4;hpb=8d6bc9bf51829ea04da5f599b84114ef220f0a19;p=ghc-hetmet.git diff --git a/compiler/coreSyn/CoreSyn.lhs b/compiler/coreSyn/CoreSyn.lhs index 86a7e9d..ac32bc2 100644 --- a/compiler/coreSyn/CoreSyn.lhs +++ b/compiler/coreSyn/CoreSyn.lhs @@ -20,9 +20,8 @@ module CoreSyn ( isTyVar, isId, cmpAltCon, cmpAlt, ltAlt, bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts, collectBinders, collectTyBinders, collectValBinders, collectTyAndValBinders, - collectArgs, - coreExprCc, - flattenBinds, + collectArgs, coreExprCc, + mkTyBind, flattenBinds, isValArg, isTypeArg, valArgCount, valBndrCount, isRuntimeArg, isRuntimeVar, @@ -150,12 +149,23 @@ Invariant: The list of alternatives is ALWAYS EXHAUSTIVE, Note [CoreSyn let goal] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~ * The simplifier tries to ensure that if the RHS of a let is a constructor application, its arguments are trivial, so that the constructor can be inlined vigorously. +Note [Type let] +~~~~~~~~~~~~~~~ +We allow a *non-recursive* let to bind a type variable, thus + Let (NonRec tv (Type ty)) body +This can be very convenient for postponing type substitutions until +the next run of the simplifier. + +At the moment, the rest of the compiler only deals with type-let +in a Let expression, rather than at top level. We may want to revist +this choice. + \begin{code} data Note = SCC CostCentre @@ -388,7 +398,7 @@ neverUnfold _ = False instance Outputable AltCon where ppr (DataAlt dc) = ppr dc ppr (LitAlt lit) = ppr lit - ppr DEFAULT = ptext SLIT("__DEFAULT") + ppr DEFAULT = ptext (sLit "__DEFAULT") instance Show AltCon where showsPrec p con = showsPrecSDoc p (ppr con) @@ -501,6 +511,11 @@ mkCast e co = Cast e co %************************************************************************ \begin{code} +mkTyBind :: TyVar -> Type -> CoreBind +mkTyBind tv ty = NonRec tv (Type ty) + -- Note [Type let] + -- A non-recursive let can bind a type variable + bindersOf :: Bind b -> [b] bindersOf (NonRec binder _) = [binder] bindersOf (Rec pairs) = [binder | (binder, _) <- pairs]