[project @ 2003-01-23 14:54:35 by simonpj]
[ghc-hetmet.git] / ghc / compiler / basicTypes / OccName.lhs
index e2a4b8f..e52a090 100644 (file)
@@ -23,6 +23,7 @@ module OccName (
        mkGenOcc1, mkGenOcc2, mkLocalOcc,
        
        isTvOcc, isTcOcc, isDataOcc, isDataSymOcc, isSymOcc, isValOcc,
+       reportIfUnused,
 
        occNameFS, occNameString, occNameUserString, occNameSpace, occNameFlavour, 
        setOccNameSpace,
@@ -257,6 +258,17 @@ isSymOcc (OccName VarName s)  = isLexSym (decodeFS s)
 \end{code}
 
 
+\begin{code}
+reportIfUnused :: OccName -> Bool
+  -- Haskell 98 encourages compilers to suppress warnings about
+  -- unused names in a pattern if they start with "_".
+reportIfUnused occ = case occNameUserString occ of
+                       ('_' : _) -> False
+                       zz_other  -> True
+\end{code}
+
+
+
 %************************************************************************
 %*                                                                     *
 \subsection{Making system names}
@@ -623,22 +635,22 @@ isLexSym cs = isLexConSym cs || isLexVarSym cs
 -------------
 
 isLexConId cs                          -- Prefix type or data constructors
-  | nullFastString cs        = False           --      e.g. "Foo", "[]", "(,)" 
+  | nullFastString cs = False          --      e.g. "Foo", "[]", "(,)" 
   | cs == FSLIT("[]") = True
   | otherwise        = startsConId (headFS cs)
 
 isLexVarId cs                          -- Ordinary prefix identifiers
-  | nullFastString cs   = False                --      e.g. "x", "_x"
-  | otherwise    = startsVarId (headFS cs)
+  | nullFastString cs = False          --      e.g. "x", "_x"
+  | otherwise         = startsVarId (headFS cs)
 
 isLexConSym cs                         -- Infix type or data constructors
-  | nullFastString cs  = False                 --      e.g. ":-:", ":", "->"
+  | nullFastString cs = False          --      e.g. ":-:", ":", "->"
   | cs == FSLIT("->") = True
-  | otherwise  = startsConSym (headFS cs)
+  | otherwise        = startsConSym (headFS cs)
 
 isLexVarSym cs                         -- Infix identifiers
-  | nullFastString cs = False                  --      e.g. "+"
-  | otherwise = startsVarSym (headFS cs)
+  | nullFastString cs = False          --      e.g. "+"
+  | otherwise         = startsVarSym (headFS cs)
 
 -------------
 startsVarSym, startsVarId, startsConSym, startsConId :: Char -> Bool