Add Data and Typeable instances to HsSyn
[ghc-hetmet.git] / compiler / basicTypes / NameSet.lhs
index 7eb5da5..c46127c 100644 (file)
@@ -30,9 +30,13 @@ module NameSet (
     ) where
 
 #include "HsVersions.h"
+#include "Typeable.h"
 
 import Name
 import UniqSet
+import Util
+
+import Data.Data
 \end{code}
 
 %************************************************************************
@@ -44,6 +48,14 @@ import UniqSet
 \begin{code}
 type NameSet = UniqSet Name
 
+INSTANCE_TYPEABLE0(NameSet,nameSetTc,"NameSet")
+
+instance Data NameSet where
+  gfoldl k z s = z mkNameSet `k` nameSetToList s -- traverse abstractly
+  toConstr _   = abstractConstr "NameSet"
+  gunfold _ _  = error "gunfold"
+  dataTypeOf _ = mkNoRepType "NameSet"
+
 emptyNameSet      :: NameSet
 unitNameSet       :: Name -> NameSet
 addListToNameSet   :: NameSet -> [Name] -> NameSet
@@ -189,7 +201,7 @@ findUses dus uses
        = rhs_uses `unionNameSets` uses
     get (Just defs, rhs_uses) uses
        | defs `intersectsNameSet` uses         -- Used
-       || not (all (reportIfUnused . nameOccName) (nameSetToList defs))
+       || any (startsWithUnderscore . nameOccName) (nameSetToList defs)
                -- At least one starts with an "_", 
                -- so treat the group as used
        = rhs_uses `unionNameSets` uses