Commit 8fc898cb authored by simonpj's avatar simonpj
Browse files

[project @ 2003-10-30 09:03:15 by simonpj]

Remove redundant param from allUses
parent e16ebb29
...@@ -145,9 +145,23 @@ mkDUs pairs = [(Just defs, uses) | (defs,uses) <- pairs] ...@@ -145,9 +145,23 @@ mkDUs pairs = [(Just defs, uses) | (defs,uses) <- pairs]
plusDU :: DefUses -> DefUses -> DefUses plusDU :: DefUses -> DefUses -> DefUses
plusDU = (++) plusDU = (++)
allUses :: DefUses -> Uses -> Uses duDefs :: DefUses -> Defs
-- Collect all uses, removing defs duDefs dus = foldr get emptyNameSet dus
allUses dus uses where
get (Nothing, u1) d2 = d2
get (Just d1, u1) d2 = d1 `unionNameSets` d2
duUses :: DefUses -> Uses
-- Just like allUses, but defs are not eliminated
duUses dus = foldr get emptyNameSet dus
where
get (d1, u1) u2 = u1 `unionNameSets` u2
allUses :: DefUses -> Uses
-- Collect all uses, regardless of
-- whether the group is itself used,
-- but remove defs on the way
allUses dus
= foldr get emptyNameSet dus = foldr get emptyNameSet dus
where where
get (Nothing, rhs_uses) uses = rhs_uses `unionNameSets` uses get (Nothing, rhs_uses) uses = rhs_uses `unionNameSets` uses
...@@ -159,7 +173,7 @@ findUses :: DefUses -> Uses -> Uses ...@@ -159,7 +173,7 @@ findUses :: DefUses -> Uses -> Uses
-- find all the uses, transitively. -- find all the uses, transitively.
-- The result is a superset of the input uses; -- The result is a superset of the input uses;
-- and includes things defined in the input DefUses -- and includes things defined in the input DefUses
-- (if they are used, of course) -- (but only if they are used)
findUses dus uses findUses dus uses
= foldr get uses dus = foldr get uses dus
where where
...@@ -170,16 +184,4 @@ findUses dus uses ...@@ -170,16 +184,4 @@ findUses dus uses
= rhs_uses `unionNameSets` uses = rhs_uses `unionNameSets` uses
| otherwise -- No def is used | otherwise -- No def is used
= uses = uses
duDefs :: DefUses -> Defs
duDefs dus = foldr get emptyNameSet dus
where
get (Nothing, u1) d2 = d2
get (Just d1, u1) d2 = d1 `unionNameSets` d2
duUses :: DefUses -> Uses
-- Defs are not eliminated
duUses dus = foldr get emptyNameSet dus
where
get (d1, u1) u2 = u1 `unionNameSets` u2
\end{code} \end{code}
\ No newline at end of file
...@@ -96,7 +96,7 @@ deSugar hsc_env ...@@ -96,7 +96,7 @@ deSugar hsc_env
(printDump (ppr_ds_rules ds_rules)) (printDump (ppr_ds_rules ds_rules))
; dfun_uses <- readIORef dfun_uses_var -- What dfuns are used ; dfun_uses <- readIORef dfun_uses_var -- What dfuns are used
; let used_names = allUses dus emptyNameSet `unionNameSets` dfun_uses ; let used_names = allUses dus `unionNameSets` dfun_uses
; usages <- mkUsageInfo hsc_env imports used_names ; usages <- mkUsageInfo hsc_env imports used_names
; let ; let
deps = Deps { dep_mods = moduleEnvElts (imp_dep_mods imports), deps = Deps { dep_mods = moduleEnvElts (imp_dep_mods imports),
......
...@@ -205,10 +205,10 @@ rnMonoBindsAndThen mbinds sigs thing_inside -- Non-empty monobinds ...@@ -205,10 +205,10 @@ rnMonoBindsAndThen mbinds sigs thing_inside -- Non-empty monobinds
warnUnusedLocalBinds unused_bndrs `thenM_` warnUnusedLocalBinds unused_bndrs `thenM_`
returnM (result, all_uses `minusNameSet` bndrs) returnM (result, all_uses `minusNameSet` bndrs)
-- It's important to return all the uses, not the 'real uses' used for -- duUses: It's important to return all the uses, not the 'real uses' used for
-- warning about unused bindings. Otherwise consider: -- warning about unused bindings. Otherwise consider:
-- x = 3 -- x = 3
-- y = let p = x in 'x' -- y = let p = x in 'x' -- NB: p not used
-- If we don't "see" the dependency of 'y' on 'x', we may put the -- If we don't "see" the dependency of 'y' on 'x', we may put the
-- bindings in the wrong order, and the type checker will complain -- bindings in the wrong order, and the type checker will complain
-- that x isn't in scope -- that x isn't in scope
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment