X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FbasicTypes%2FOccName.lhs;h=29a6bbc2fb3ba77ea140f9d9b574ff1caf5d1f5c;hb=8e67f5502e2e316245806ee3735a2f41a844b611;hp=50b39fe7f004ab95d866f4e24f01c61a884dac03;hpb=0e2c58247410a9317064bbddbf294644c0300b14;p=ghc-hetmet.git diff --git a/ghc/compiler/basicTypes/OccName.lhs b/ghc/compiler/basicTypes/OccName.lhs index 50b39fe..29a6bbc 100644 --- a/ghc/compiler/basicTypes/OccName.lhs +++ b/ghc/compiler/basicTypes/OccName.lhs @@ -35,7 +35,7 @@ module OccName ( mkDataConWrapperOcc, mkDataConWorkerOcc, isVarOcc, isTvOcc, isTcOcc, isDataOcc, isDataSymOcc, isSymOcc, isValOcc, - reportIfUnused, + parenSymOcc, reportIfUnused, occNameFS, occNameString, occNameUserString, occNameSpace, occNameFlavour, briefOccNameFlavour, @@ -402,9 +402,15 @@ isDataOcc other = False -- Any operator (data constructor or variable) -- Pretty inefficient! -isSymOcc (OccName DataName s) = isLexConSym (decodeFS s) -isSymOcc (OccName VarName s) = isLexSym (decodeFS s) -isSymOcc other = False +isSymOcc (OccName DataName s) = isLexConSym (decodeFS s) +isSymOcc (OccName TcClsName s) = isLexConSym (decodeFS s) +isSymOcc (OccName VarName s) = isLexSym (decodeFS s) +isSymOcc other = False + +parenSymOcc :: OccName -> SDoc -> SDoc +-- Wrap parens around an operator +parenSymOcc occ doc | isSymOcc occ = parens doc + | otherwise = doc \end{code} @@ -753,6 +759,19 @@ decode_num_esc d rest go n (c : rest) | isDigit c = go (10*n + digitToInt c) rest go n ('U' : rest) = chr n : decode rest go n other = pprPanic "decode_num_esc" (ppr n <+> text other) + +decode_tuple :: Char -> EncodedString -> UserString +decode_tuple d rest + = go (digitToInt d) rest + where + -- NB. recurse back to decode after decoding the tuple, because + -- the tuple might be embedded in a longer name. + go n (c : rest) | isDigit c = go (10*n + digitToInt c) rest + go 0 ('T':rest) = "()" ++ decode rest + go n ('T':rest) = '(' : replicate (n-1) ',' ++ ")" ++ decode rest + go 1 ('H':rest) = "(# #)" ++ decode rest + go n ('H':rest) = '(' : '#' : replicate (n-1) ',' ++ "#)" ++ decode rest + go n other = pprPanic "decode_tuple" (ppr n <+> text other) \end{code} @@ -793,17 +812,6 @@ count_commas n cs = (n,cs) \end{code} \begin{code} -decode_tuple :: Char -> EncodedString -> UserString -decode_tuple d rest - = go (digitToInt d) rest - where - go n (c : rest) | isDigit c = go (10*n + digitToInt c) rest - go 0 ['T'] = "()" - go n ['T'] = '(' : replicate (n-1) ',' ++ ")" - go 1 ['H'] = "(# #)" - go n ['H'] = '(' : '#' : replicate (n-1) ',' ++ "#)" - go n other = pprPanic "decode_tuple" (ppr n <+> text other) - mkTupleOcc :: NameSpace -> Boxity -> Arity -> OccName mkTupleOcc ns bx ar = OccName ns (mkFastString ('Z' : (show ar ++ bx_char)))