X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreSyn.lhs;h=ea22eb585b1cdcfdc21ad3fb7ae483d19a6f61e7;hp=f732a95fba2aa3ca50114c0527a331535607889b;hb=6084fb5517da34f65034370a3695e2af3b85ce2b;hpb=6c9e4b5ab835c220ce849537b5d885c9d5382bef diff --git a/compiler/coreSyn/CoreSyn.lhs b/compiler/coreSyn/CoreSyn.lhs index f732a95..ea22eb5 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, @@ -43,13 +42,14 @@ module CoreSyn ( -- Core rules CoreRule(..), -- CoreSubst, CoreTidy, CoreFVs, PprCore only RuleName, seqRules, ruleArity, - isBuiltinRule, ruleName, isLocalRule, ruleIdName + isBuiltinRule, ruleName, isLocalRule, ruleIdName, setRuleIdName ) where #include "HsVersions.h" import CostCentre import Var +import Id import Type import Coercion import Name @@ -150,12 +150,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 @@ -195,8 +206,6 @@ A Rule is as the rule itself \begin{code} -type RuleName = FastString - data CoreRule = Rule { ru_name :: RuleName, @@ -252,6 +261,9 @@ ruleIdName = ru_fn isLocalRule :: CoreRule -> Bool isLocalRule = ru_local + +setRuleIdName :: Name -> CoreRule -> CoreRule +setRuleIdName nm ru = ru { ru_fn = nm } \end{code} @@ -501,6 +513,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]