Use OPTIONS rather than OPTIONS_GHC for pragmas
[ghc-hetmet.git] / compiler / basicTypes / OccName.lhs
index 92351d6..2f8a632 100644 (file)
@@ -4,6 +4,13 @@
 %
 
 \begin{code}
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings
+-- for details
+
 module OccName (
        -- * The NameSpace type; abstact
        NameSpace, tcName, clsName, tcClsName, dataName, varName, 
@@ -31,7 +38,11 @@ module OccName (
        mkSpecOcc, mkForeignExportOcc, mkGenOcc1, mkGenOcc2,
        mkDataTOcc, mkDataCOcc, mkDataConWorkerOcc,
        mkSuperDictSelOcc, mkLocalOcc, mkMethodOcc, mkInstTyTcOcc,
-       mkInstTyCoOcc, 
+       mkInstTyCoOcc, mkEqPredCoOcc,
+        mkVectOcc, mkVectTyConOcc, mkVectDataConOcc, mkVectIsoOcc,
+        mkPArrayTyConOcc, mkPArrayDataConOcc,
+        mkPReprTyConOcc,
+        mkPADFunOcc,
 
        -- ** Deconstruction
        occNameFS, occNameString, occNameSpace, 
@@ -43,7 +54,7 @@ module OccName (
 
        -- The OccEnv type
        OccEnv, emptyOccEnv, unitOccEnv, extendOccEnv, mapOccEnv,
-       lookupOccEnv, mkOccEnv, extendOccEnvList, elemOccEnv,
+       lookupOccEnv, mkOccEnv, mkOccEnv_C, extendOccEnvList, elemOccEnv,
        occEnvElts, foldOccEnv, plusOccEnv, plusOccEnv_C, extendOccEnv_C,
 
        -- The OccSet type
@@ -78,7 +89,6 @@ import Data.Char
 
 -- Unicode TODO: put isSymbol in libcompat
 #if __GLASGOW_HASKELL__ > 604
-import Data.Char       ( isSymbol )
 #else
 isSymbol = const False
 #endif
@@ -92,8 +102,8 @@ isSymbol = const False
 %************************************************************************
 
 \begin{code}
-data NameSpace = VarName       -- Variables, including "source" data constructors
-              | DataName       -- "Real" data constructors 
+data NameSpace = VarName       -- Variables, including "real" data constructors
+              | DataName       -- "Source" data constructors 
               | TvName         -- Type variables
               | TcClsName      -- Type constructors and classes; Haskell has them
                                -- in the same name space for now.
@@ -176,8 +186,9 @@ instance Eq OccName where
     (OccName sp1 s1) == (OccName sp2 s2) = s1 == s2 && sp1 == sp2
 
 instance Ord OccName where
-    compare (OccName sp1 s1) (OccName sp2 s2) = (s1  `compare` s2) `thenCmp`
-                                               (sp1 `compare` sp2)
+       -- Compares lexicographically, *not* by Unique of the string
+    compare (OccName sp1 s1) (OccName sp2 s2) 
+       = (s1  `compare` s2) `thenCmp` (sp1 `compare` sp2)
 \end{code}
 
 
@@ -259,6 +270,7 @@ extendOccEnv :: OccEnv a -> OccName -> a -> OccEnv a
 extendOccEnvList :: OccEnv a -> [(OccName, a)] -> OccEnv a
 lookupOccEnv :: OccEnv a -> OccName -> Maybe a
 mkOccEnv     :: [(OccName,a)] -> OccEnv a
+mkOccEnv_C   :: (a -> a -> a) -> [(OccName,a)] -> OccEnv a
 elemOccEnv   :: OccName -> OccEnv a -> Bool
 foldOccEnv   :: (a -> b -> b) -> b -> OccEnv a -> b
 occEnvElts   :: OccEnv a -> [a]
@@ -281,6 +293,8 @@ plusOccEnv_C         = plusUFM_C
 extendOccEnv_C   = addToUFM_C
 mapOccEnv       = mapUFM
 
+mkOccEnv_C comb l = addListToUFM_C comb emptyOccEnv l
+
 type OccSet = UniqFM OccName
 
 emptyOccSet      :: OccSet
@@ -398,6 +412,7 @@ Here's our convention for splitting up the interface file name space:
        $w...           workers
        :T...           compiler-generated tycons for dictionaries
        :D...           ...ditto data cons
+        :Co...          ...ditto coercions
        $sf..           specialised version of f
 
        in encoded form these appear as Zdfxxx etc
@@ -440,7 +455,8 @@ mkIPOcc                 = mk_simple_deriv varName  "$i"
 mkSpecOcc          = mk_simple_deriv varName  "$s"
 mkForeignExportOcc  = mk_simple_deriv varName  "$f"
 mkNewTyCoOcc        = mk_simple_deriv tcName  ":Co"
-mkInstTyCoOcc       = mk_simple_deriv tcName  ":Co"      -- derived from rep ty
+mkInstTyCoOcc       = mk_simple_deriv tcName  ":CoF"     -- derived from rep ty
+mkEqPredCoOcc      = mk_simple_deriv tcName  "$co"
 
 -- Generic derivable classes
 mkGenOcc1           = mk_simple_deriv varName  "$gfrom"
@@ -452,6 +468,16 @@ mkGenOcc2           = mk_simple_deriv varName  "$gto"
 mkDataTOcc = mk_simple_deriv varName  "$t"
 mkDataCOcc = mk_simple_deriv varName  "$c"
 
+-- Vectorisation
+mkVectOcc          = mk_simple_deriv varName  "$v_"
+mkVectTyConOcc     = mk_simple_deriv tcName   ":V_"
+mkVectDataConOcc   = mk_simple_deriv dataName ":VD_"
+mkVectIsoOcc       = mk_simple_deriv varName  "$VI_"
+mkPArrayTyConOcc   = mk_simple_deriv tcName   ":VP_"
+mkPArrayDataConOcc = mk_simple_deriv dataName ":VPD_"
+mkPReprTyConOcc    = mk_simple_deriv tcName   ":VR_"
+mkPADFunOcc        = mk_simple_deriv varName  "$PA_"
+
 mk_simple_deriv sp px occ = mk_deriv sp px (occNameString occ)
 
 -- Data constructor workers are made by setting the name space