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]
plusDU :: DefUses -> DefUses -> DefUses
plusDU = (++)
allUses :: DefUses -> Uses -> Uses
-- Collect all uses, removing defs
allUses dus 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
-- 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
where
get (Nothing, rhs_uses) uses = rhs_uses `unionNameSets` uses
......@@ -159,7 +173,7 @@ findUses :: DefUses -> Uses -> Uses
-- find all the uses, transitively.
-- The result is a superset of the input uses;
-- and includes things defined in the input DefUses
-- (if they are used, of course)
-- (but only if they are used)
findUses dus uses
= foldr get uses dus
where
......@@ -170,16 +184,4 @@ findUses dus uses
= rhs_uses `unionNameSets` uses
| otherwise -- No def is used
= 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}
\ No newline at end of file
......@@ -96,7 +96,7 @@ deSugar hsc_env
(printDump (ppr_ds_rules ds_rules))
; 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
; let
deps = Deps { dep_mods = moduleEnvElts (imp_dep_mods imports),
......
......@@ -205,10 +205,10 @@ rnMonoBindsAndThen mbinds sigs thing_inside -- Non-empty monobinds
warnUnusedLocalBinds unused_bndrs `thenM_`
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:
-- 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
-- bindings in the wrong order, and the type checker will complain
-- 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