[project @ 1996-05-01 18:36:59 by partain]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Name.lhs
index 303fd04..fcb4ecf 100644 (file)
@@ -48,7 +48,7 @@ module Name (
        getLocalName, ltLexical,
 
        isSymLexeme, pprSym, pprNonSym,
-       isLexCon, isLexVar, isLexId, isLexSym,
+       isLexCon, isLexVar, isLexId, isLexSym, isLexSpecialSym,
        isLexConId, isLexConSym, isLexVarId, isLexVarSym
     ) where
 
@@ -123,7 +123,6 @@ instance Outputable RdrName where
     ppr sty (Unqual n) = pp_name sty n
     ppr sty (Qual m n) = ppBeside (pp_mod sty m) (pp_name sty n)
 
-pp_mod PprInterface        m = ppNil
 pp_mod PprForC             m = ppBesides [identToC m, ppPStr cSEP]
 pp_mod (PprForAsm False _) m = ppBesides [identToC m, ppPStr cSEP]
 pp_mod (PprForAsm True  _) m = ppBesides [ppPStr cSEP, identToC m, ppPStr cSEP]
@@ -351,12 +350,6 @@ exportFlagOn NotExported = False
 exportFlagOn _          = True
 
 isExported a = exportFlagOn (getExportFlag a)
-
-#ifdef USE_ATTACK_PRAGMAS
-{-# SPECIALIZE isExported :: Class -> Bool #-}
-{-# SPECIALIZE isExported :: Id -> Bool #-}
-{-# SPECIALIZE isExported :: TyCon -> Bool #-}
-#endif
 \end{code}
 
 %************************************************************************
@@ -410,12 +403,6 @@ comparison.]
 
 \begin{code}
 a `ltLexical` b = origName a < origName b
-
-#ifdef USE_ATTACK_PRAGMAS
-{-# SPECIALIZE ltLexical :: Class -> Class -> Bool #-}
-{-# SPECIALIZE ltLexical :: Id    -> Id    -> Bool #-}
-{-# SPECIALIZE ltLexical :: TyCon -> TyCon -> Bool #-}
-#endif
 \end{code}
 
 These functions test strings to see if they fit the lexical categories
@@ -423,7 +410,8 @@ defined in the Haskell report.  Normally applied as in e.g. @isCon
 (getLocalName foo)@.
 
 \begin{code}
-isLexCon, isLexVar, isLexId, isLexSym, isLexConId, isLexConSym, isLexVarId, isLexVarSym :: FAST_STRING -> Bool
+isLexCon, isLexVar, isLexId, isLexSym, isLexConId, isLexConSym,
+ isLexVarId, isLexVarSym, isLexSpecialSym :: FAST_STRING -> Bool
 
 isLexCon cs = isLexConId  cs || isLexConSym cs
 isLexVar cs = isLexVarId  cs || isLexVarSym cs
@@ -449,10 +437,10 @@ isLexVarId cs
 
 isLexConSym cs
   | _NULL_ cs  = False
-  | otherwise  = c == ':'
-              || c == '('      -- (), (,), (,,), ...
+  | otherwise  = c  == ':'
+--            || c  == '('     -- (), (,), (,,), ...
               || cs == SLIT("->")
-              || cs == SLIT("[]")
+--            || cs == SLIT("[]")
   where
     c = _HEAD_ cs
 
@@ -460,7 +448,14 @@ isLexVarSym cs
   | _NULL_ cs = False
   | otherwise = isSymbolASCII c
             || isSymbolISO c
-            || c == '('        -- (), (,), (,,), ...
+--          || c  == '('       -- (), (,), (,,), ...
+--          || cs == SLIT("[]")
+  where
+    c = _HEAD_ cs
+
+isLexSpecialSym cs
+  | _NULL_ cs = False
+  | otherwise = c  == '('      -- (), (,), (,,), ...
             || cs == SLIT("[]")
   where
     c = _HEAD_ cs
@@ -484,19 +479,15 @@ isSymLexeme v
 pprSym, pprNonSym :: (NamedThing name, Outputable name) => PprStyle -> name -> Pretty
 
 pprSym sty var
-  = if isSymLexeme var
+  = let
+       str = nameOf (origName var)
+    in
+    if isLexSym str && not (isLexSpecialSym str)
     then ppr sty var
     else ppBesides [ppChar '`', ppr sty var, ppChar '`']
 
 pprNonSym sty var
   = if isSymLexeme var
-    then ppBesides [ppLparen, ppr sty var, ppRparen]
+    then ppParens (ppr sty var)
     else ppr sty var
-
-#ifdef USE_ATTACK_PRAGMAS
-{-# SPECIALIZE isSymLexeme :: Id -> Bool #-}
-{-# SPECIALIZE pprNonSym :: PprStyle -> Id -> Pretty #-}
-{-# SPECIALIZE pprNonSym :: PprStyle -> TyCon -> Pretty #-}
-{-# SPECIALIZE pprSym :: PprStyle -> Id -> Pretty #-}
-#endif
 \end{code}