X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FOccName.lhs;h=a5b32edf68dbd3dbd331c32d7281303d7f2d40e4;hb=680f11d3f1ad9065c4969ed5d9db857cc245d778;hp=3465f554bb4eb395738f17a80c5f1a21c99a489d;hpb=6791ad226806d7b4e7618c91516e9e20be882813;p=ghc-hetmet.git diff --git a/compiler/basicTypes/OccName.lhs b/compiler/basicTypes/OccName.lhs index 3465f55..a5b32ed 100644 --- a/compiler/basicTypes/OccName.lhs +++ b/compiler/basicTypes/OccName.lhs @@ -1,10 +1,8 @@ -{-% 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} module OccName ( -- * The NameSpace type; abstact @@ -45,7 +43,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,19 +63,18 @@ 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 @@ -262,6 +259,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 +282,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 @@ -401,6 +401,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,7 +443,8 @@ 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" +mkNewTyCoOcc = mk_simple_deriv tcName ":Co" +mkInstTyCoOcc = mk_simple_deriv tcName ":Co" -- derived from rep ty -- Generic derivable classes mkGenOcc1 = mk_simple_deriv varName "$gfrom" @@ -478,25 +480,15 @@ mkLocalOcc uniq occ -- that need encoding (e.g. 'z'!) \end{code} -\begin{code} +Derive a name for the representation type constructor of a data/newtype +instance. --- Derive a name for the representation type constructor of a data/newtype --- instance. --- -mkInstTyTcOcc :: Unique -- Unique - -> OccName -- Local name (e.g. "Map") +\begin{code} +mkInstTyTcOcc :: Int -- Index + -> OccName -- Family name (e.g. "Map") -> OccName -- Nice unique version (":R23Map") -mkInstTyTcOcc uniq occ - = mk_deriv varName (":R" ++ show uniq) (occNameString occ) - --- Derive a name for the coercion of a data/newtype instance. --- -mkInstTyCoOcc :: Unique -- Unique - -> OccName -- Local name (e.g. "Map") - -> OccName -- Nice unique version ("Co23Map") -mkInstTyCoOcc uniq occ - = mk_deriv varName ("Co" ++ show uniq) (occNameString occ) - +mkInstTyTcOcc index occ + = mk_deriv tcName (":R" ++ show index) (occNameString occ) \end{code} \begin{code}