[project @ 2004-08-16 09:51:20 by simonpj]
[ghc-hetmet.git] / ghc / compiler / coreSyn / CoreFVs.lhs
index 0bce99b..384add2 100644 (file)
@@ -11,8 +11,7 @@ module CoreFVs (
        exprSomeFreeVars, exprsSomeFreeVars,
 
        idRuleVars, idFreeVars, idFreeTyVars,
-       ruleSomeFreeVars, ruleRhsFreeVars,
-       ruleLhsFreeNames, ruleLhsFreeIds, 
+       ruleRhsFreeVars, ruleLhsFreeNames, ruleLhsFreeIds, 
 
        CoreExprWithFVs,        -- = AnnExpr Id VarSet
        CoreBindWithFVs,        -- = AnnBind Id VarSet
@@ -28,7 +27,7 @@ import NameSet
 import VarSet
 import Var             ( Var, isId, isLocalVar, varName )
 import Type            ( tyVarsOfType )
-import TcType          ( namesOfType )
+import TcType          ( tyClsNamesOfType )
 import Util            ( mapAndUnzip )
 import Outputable
 \end{code}
@@ -152,7 +151,7 @@ expr_fvs (Let (Rec pairs) body)
 exprFreeNames finds the free *names* of an expression, notably
 including the names of type constructors (which of course do not show
 up in exprFreeVars).  Similarly ruleLhsFreeNames.  The latter is used
-when deciding whethera rule is an orphan.  In particular, suppose that
+when deciding whether a rule is an orphan.  In particular, suppose that
 T is defined in this module; we want to avoid declaring that a rule like
        fromIntegral T = fromIntegral_T
 is an orphan.  Of course it isn't, an declaring it an orphan would
@@ -165,9 +164,9 @@ ruleLhsFreeNames (fn, Rule _ _ tpl_vars tpl_args rhs)
   = addOneToNameSet (exprsFreeNames tpl_args `del_binders` tpl_vars) (varName fn)
 
 exprFreeNames :: CoreExpr -> NameSet
-exprFreeNames (Var v)  = unitNameSet (varName v)
-exprFreeNames (Lit _)  = emptyNameSet
-exprFreeNames (Type ty) = namesOfType ty
+exprFreeNames (Var v)    = unitNameSet (varName v)
+exprFreeNames (Lit _)    = emptyNameSet
+exprFreeNames (Type ty)   = tyClsNamesOfType ty        -- Don't need free tyvars
 exprFreeNames (App e1 e2) = exprFreeNames e1 `unionNameSets` exprFreeNames e2
 exprFreeNames (Lam v e)   = exprFreeNames e `delFromNameSet` varName v
 exprFreeNames (Note n e)  = exprFreeNames e
@@ -207,14 +206,6 @@ ruleRhsFreeVars (Rule str _ tpl_vars tpl_args rhs)
   where
     rule_fvs = addBndrs tpl_vars (expr_fvs rhs)
 
-ruleSomeFreeVars :: InterestingVarFun -> CoreRule -> VarSet
-ruleSomeFreeVars interesting (BuiltinRule _ _) = noFVs
-ruleSomeFreeVars interesting (Rule _ _ tpl_vars tpl_args rhs)
-  = rule_fvs interesting emptyVarSet
-  where
-    rule_fvs = addBndrs tpl_vars $
-              foldr (union . expr_fvs) (expr_fvs rhs) tpl_args
-
 ruleLhsFreeIds :: CoreRule -> VarSet
 -- This finds all the free Ids on the LHS of the rule
 -- *including* imported ids