X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FOccName.lhs;h=13978e28f0efbc48dbc4c15a1e407d1c635e3f92;hb=e932508283461bfc5b6658a374fd6e9126979e49;hp=cae76a6b1be7920a6350c7090b6ce0d4b0d75a8a;hpb=5043f5905a26ba8a2eb65cb5283abf41db87528c;p=ghc-hetmet.git diff --git a/compiler/basicTypes/OccName.lhs b/compiler/basicTypes/OccName.lhs index cae76a6..13978e2 100644 --- a/compiler/basicTypes/OccName.lhs +++ b/compiler/basicTypes/OccName.lhs @@ -1,11 +1,16 @@ -{-% DrIFT (Automatic class derivations for Haskell) v1.1 %-} % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[OccName]{@OccName@} - \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/Commentary/CodingStyle#Warnings +-- for details + module OccName ( -- * The NameSpace type; abstact NameSpace, tcName, clsName, tcClsName, dataName, varName, @@ -33,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, @@ -45,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 @@ -65,23 +74,21 @@ module OccName ( #include "HsVersions.h" -import Util ( thenCmp ) -import Unique ( Unique, mkUnique, Uniquable(..) ) -import BasicTypes ( Boxity(..), Arity ) -import StaticFlags ( opt_PprStyle_Debug ) +import Util +import Unique +import BasicTypes +import StaticFlags import UniqFM import UniqSet import FastString import Outputable import Binary -import GLAEXTS - -import Data.Char ( isUpper, isLower, ord ) +import GHC.Exts +import Data.Char -- Unicode TODO: put isSymbol in libcompat #if __GLASGOW_HASKELL__ > 604 -import Data.Char ( isSymbol ) #else isSymbol = const False #endif @@ -95,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. @@ -179,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} @@ -262,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] @@ -284,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 @@ -365,7 +376,7 @@ isDataOcc other = False isSymOcc (OccName DataName s) = isLexConSym s isSymOcc (OccName TcClsName s) = isLexConSym s isSymOcc (OccName VarName s) = isLexSym s -isSymOcc other = False +isSymOcc (OccName TvName s) = isLexSym s parenSymOcc :: OccName -> SDoc -> SDoc -- Wrap parens around an operator @@ -401,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 @@ -442,8 +454,9 @@ mkDictOcc = mk_simple_deriv varName "$d" 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 +mkNewTyCoOcc = mk_simple_deriv tcName ":Co" +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" @@ -455,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