-ruleLhsFreeNames :: CoreRule -> NameSet
-ruleLhsFreeNames (BuiltinRule { ru_fn = fn }) = unitNameSet fn
-ruleLhsFreeNames (Rule { ru_fn = fn, ru_bndrs = tpl_vars, ru_args = tpl_args })
- = addOneToNameSet (exprsFreeNames tpl_args) fn
-
-exprFreeNames :: CoreExpr -> NameSet
--- Find the free *external* names of an expression
-exprFreeNames e
+-- | ruleLhsOrphNames is used 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, and declaring it an orphan would
+-- make the whole module an orphan module, which is bad.
+ruleLhsOrphNames :: CoreRule -> NameSet
+ruleLhsOrphNames (BuiltinRule { ru_fn = fn }) = unitNameSet fn
+ruleLhsOrphNames (Rule { ru_fn = fn, ru_args = tpl_args })
+ = addOneToNameSet (exprsOrphNames tpl_args) fn
+ -- No need to delete bndrs, because
+ -- exprsOrphNames finds only External names
+
+-- | Finds the free /external/ names of an expression, notably
+-- including the names of type constructors (which of course do not show
+-- up in 'exprFreeVars').
+exprOrphNames :: CoreExpr -> NameSet
+-- There's no need to delete local binders, because they will all
+-- be /internal/ names.
+exprOrphNames e