X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FOccName.lhs;h=10cf91eb790d2e4ed44f59c155dce936931c5042;hb=432b9c9322181a3644083e3c19b7e240d90659e7;hp=1868c3f91895ebce986ef70ad0e2a15eb247e3e0;hpb=3aafdc1609ee60c4d5629b279c45ccbb943fa4a7;p=ghc-hetmet.git diff --git a/compiler/basicTypes/OccName.lhs b/compiler/basicTypes/OccName.lhs index 1868c3f..10cf91e 100644 --- a/compiler/basicTypes/OccName.lhs +++ b/compiler/basicTypes/OccName.lhs @@ -65,7 +65,7 @@ module OccName ( occNameFS, occNameString, occNameSpace, isVarOcc, isTvOcc, isTcOcc, isDataOcc, isDataSymOcc, isSymOcc, isValOcc, - parenSymOcc, reportIfUnused, + parenSymOcc, startsWithUnderscore, isTcClsNameSpace, isTvNameSpace, isDataConNameSpace, isVarNameSpace, isValNameSpace, @@ -463,13 +463,12 @@ parenSymOcc occ doc | isSymOcc occ = parens doc \begin{code} -reportIfUnused :: OccName -> Bool --- ^ Haskell 98 encourages compilers to suppress warnings about --- unused names in a pattern if they start with @_@: this implements --- that test -reportIfUnused occ = case occNameString occ of - ('_' : _) -> False - _other -> True +startsWithUnderscore :: OccName -> Bool +-- ^ Haskell 98 encourages compilers to suppress warnings about unsed +-- names in a pattern if they start with @_@: this implements that test +startsWithUnderscore occ = case occNameString occ of + ('_' : _) -> True + _other -> False \end{code} @@ -481,19 +480,24 @@ reportIfUnused occ = case occNameString occ of Here's our convention for splitting up the interface file name space: - d... dictionary identifiers - (local variables, so no name-clash worries) + d... dictionary identifiers + (local variables, so no name-clash worries) - \$f... dict-fun identifiers (from inst decls) - \$dm... default methods - \$p... superclass selectors - \$w... workers - :T... compiler-generated tycons for dictionaries - :D... ...ditto data cons - :Co... ...ditto coercions - \$sf.. specialised version of f +All of these other OccNames contain a mixture of alphabetic +and symbolic characters, and hence cannot possibly clash with +a user-written type or function name - in encoded form these appear as Zdfxxx etc + $f... Dict-fun identifiers (from inst decls) + $dmop Default method for 'op' + $pnC n'th superclass selector for class C + $wf Worker for functtoin 'f' + $sf.. Specialised version of f + T:C Tycon for dictionary for class C + D:C Data constructor for dictionary for class C + NTCo:T Coercion connecting newtype T with its representation type + TFCo:R Coercion connecting a data family to its respresentation type R + +In encoded form these appear as Zdfxxx etc :... keywords (export:, letrec: etc.) --- I THINK THIS IS WRONG! @@ -535,15 +539,15 @@ mkDataConWrapperOcc = mk_simple_deriv varName "$W" mkWorkerOcc = mk_simple_deriv varName "$w" mkDefaultMethodOcc = mk_simple_deriv varName "$dm" mkDerivedTyConOcc = mk_simple_deriv tcName ":" -- The : prefix makes sure it classifies -mkClassTyConOcc = mk_simple_deriv tcName ":T" -- as a tycon/datacon -mkClassDataConOcc = mk_simple_deriv dataName ":D" -- We go straight to the "real" data con +mkClassTyConOcc = mk_simple_deriv tcName "T:" -- as a tycon/datacon +mkClassDataConOcc = mk_simple_deriv dataName "D:" -- We go straight to the "real" data con -- for datacons from classes 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 ":CoF" -- derived from rep ty +mkNewTyCoOcc = mk_simple_deriv tcName "NTCo:" -- Coercion for newtypes +mkInstTyCoOcc = mk_simple_deriv tcName "TFCo:" -- Coercion for type functions mkEqPredCoOcc = mk_simple_deriv tcName "$co" -- used in derived instances @@ -597,13 +601,13 @@ mkLocalOcc uniq occ \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 :: Int -- ^ DFun Index -> OccName -- ^ Family name, e.g. @Map@ -> OccName -- ^ Nice unique version, e.g. @:R23Map@ mkInstTyTcOcc index occ - = mk_deriv tcName (":R" ++ show index) (occNameString occ) + = mk_deriv tcName ("R" ++ show index ++ ":") (occNameString occ) \end{code} \begin{code}