X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreTidy.lhs;h=586f032b32e42fd23faf1df58ad2c0b5b2ea19e8;hb=d95ce839533391e7118257537044f01cbb1d6694;hp=37c6cb353b9d43c9fc855c0eb42bbc6977f41f25;hpb=7fc749a43b4b6b85d234fa95d4928648259584f4;p=ghc-hetmet.git diff --git a/compiler/coreSyn/CoreTidy.lhs b/compiler/coreSyn/CoreTidy.lhs index 37c6cb3..586f032 100644 --- a/compiler/coreSyn/CoreTidy.lhs +++ b/compiler/coreSyn/CoreTidy.lhs @@ -7,13 +7,6 @@ This module contains "tidying" code for *nested* expressions, bindings, rules. The code for *top-level* bindings is in TidyPgm. \begin{code} -{-# OPTIONS -w #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings --- for details - module CoreTidy ( tidyExpr, tidyVarOcc, tidyRule, tidyRules ) where @@ -62,7 +55,7 @@ tidyBind env (Rec prs) tidyExpr :: TidyEnv -> CoreExpr -> CoreExpr tidyExpr env (Var v) = Var (tidyVarOcc env v) tidyExpr env (Type ty) = Type (tidyType env ty) -tidyExpr env (Lit lit) = Lit lit +tidyExpr _ (Lit lit) = Lit lit tidyExpr env (App f a) = App (tidyExpr env f) (tidyExpr env a) tidyExpr env (Note n e) = Note (tidyNote env n) (tidyExpr env e) tidyExpr env (Cast e co) = Cast (tidyExpr env e) (tidyType env co) @@ -81,23 +74,25 @@ tidyExpr env (Lam b e) Lam b (tidyExpr env' e) ------------ Case alternatives -------------- -tidyAlt case_bndr env (con, vs, rhs) +tidyAlt :: CoreBndr -> TidyEnv -> CoreAlt -> CoreAlt +tidyAlt _case_bndr env (con, vs, rhs) = tidyBndrs env vs =: \ (env', vs) -> (con, vs, tidyExpr env' rhs) ------------ Notes -------------- -tidyNote env note = note +tidyNote :: TidyEnv -> Note -> Note +tidyNote _ note = note ------------ Rules -------------- tidyRules :: TidyEnv -> [CoreRule] -> [CoreRule] -tidyRules env [] = [] +tidyRules _ [] = [] tidyRules env (rule : rules) = tidyRule env rule =: \ rule -> tidyRules env rules =: \ rules -> (rule : rules) tidyRule :: TidyEnv -> CoreRule -> CoreRule -tidyRule env rule@(BuiltinRule {}) = rule +tidyRule _ rule@(BuiltinRule {}) = rule tidyRule env rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs, ru_fn = fn, ru_rough = mb_ns }) = tidyBndrs env bndrs =: \ (env', bndrs) -> @@ -181,17 +176,24 @@ tidyIdBndr env@(tidy_env, var_env) id -- though we could extract it from the Id -- -- All nested Ids now have the same IdInfo, namely vanillaIdInfo, - -- which should save some space. + -- which should save some space; except that we hang onto dead-ness + -- (at the moment, solely to make printing tidy core nicer) -- But note that tidyLetBndr puts some of it back. - ty' = tidyType env (idType id) - id' = mkUserLocal occ' (idUnique id) ty' noSrcSpan - `setIdInfo` vanillaIdInfo - var_env' = extendVarEnv var_env id id' + ty' = tidyType env (idType id) + name' = mkInternalName (idUnique id) occ' noSrcSpan + id' = mkLocalIdWithInfo name' ty' new_info + var_env' = extendVarEnv var_env id id' + new_info | isDeadOcc (idOccInfo id) = deadIdInfo + | otherwise = vanillaIdInfo in ((tidy_env', var_env'), id') } + +deadIdInfo :: IdInfo +deadIdInfo = vanillaIdInfo `setOccInfo` IAmDead \end{code} \begin{code} +(=:) :: a -> (a -> b) -> b m =: k = m `seq` k m \end{code}