diff options
author | simonpj@microsoft.com <unknown> | 2010-03-04 12:38:22 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2010-03-04 12:38:22 +0000 |
commit | 4623207393db41c970e713c326e9b54aa017dc3a (patch) | |
tree | 8fc86b1356eaa3be5df2cd10c1f805ea2eb51f5c | |
parent | d60d5996635f751d641fe29db6bde59822019235 (diff) | |
download | haskell-4623207393db41c970e713c326e9b54aa017dc3a.tar.gz |
Two things to do with -dsuppress-uniques
a) Even with -dsuppress-uniques, don't suppress them when outputing
code, else the assembler falls over bleating
b) Do suppress uniques in names generated by TH. It's a bit grungy
to do this: see Note [Suppressing uniques in OccNames]. But
it's only needed for test de-wobblification so the grunge isn't
really important.
-rw-r--r-- | compiler/basicTypes/OccName.lhs | 23 | ||||
-rw-r--r-- | compiler/basicTypes/Unique.lhs | 8 |
2 files changed, 23 insertions, 8 deletions
diff --git a/compiler/basicTypes/OccName.lhs b/compiler/basicTypes/OccName.lhs index 8248b5f57c..172c7097b3 100644 --- a/compiler/basicTypes/OccName.lhs +++ b/compiler/basicTypes/OccName.lhs @@ -100,6 +100,7 @@ import UniqSet import FastString import Outputable import Binary +import StaticFlags( opt_SuppressUniques ) import Data.Char \end{code} @@ -243,12 +244,26 @@ pprOccName :: OccName -> SDoc pprOccName (OccName sp occ) = getPprStyle $ \ sty -> if codeStyle sty - then ftext (zEncodeFS occ) - else ftext occ <> if debugStyle sty - then braces (pprNameSpaceBrief sp) - else empty + then ftext (zEncodeFS occ) + else pp_occ <> pp_debug sty + where + pp_debug sty | debugStyle sty = braces (pprNameSpaceBrief sp) + | otherwise = empty + + pp_occ | opt_SuppressUniques = text (strip_th_unique (unpackFS occ)) + | otherwise = ftext occ + + -- See Note [Suppressing uniques in OccNames] + strip_th_unique ('[' : c : _) | isAlphaNum c = [] + strip_th_unique (c : cs) = c : strip_th_unique cs + strip_th_unique [] = [] \end{code} +Note [Suppressing uniques in OccNames] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This is a hack to de-wobblify the OccNames that contain uniques from +Template Haskell that have been turned into a string in the OccName. +See Note [Unique OccNames from Template Haskell] in Convert.hs %************************************************************************ %* * diff --git a/compiler/basicTypes/Unique.lhs b/compiler/basicTypes/Unique.lhs index 1ef0ca8590..6e0ee20ead 100644 --- a/compiler/basicTypes/Unique.lhs +++ b/compiler/basicTypes/Unique.lhs @@ -62,7 +62,7 @@ import BasicTypes import FastTypes import FastString import Outputable -import StaticFlags +-- import StaticFlags #if defined(__GLASGOW_HASKELL__) --just for implementing a fast [0,61) -> Char function @@ -215,9 +215,9 @@ We do sometimes make strings with @Uniques@ in them: \begin{code} pprUnique :: Unique -> SDoc pprUnique uniq - | opt_SuppressUniques - = empty -- Used exclusively to suppress uniques so you - | otherwise -- can compare output easily +-- | opt_SuppressUniques +-- = empty -- Used exclusively to suppress uniques so you +-- | otherwise -- can compare output easily = case unpkUnique uniq of (tag, u) -> finish_ppr tag u (text (iToBase62 u)) |