summaryrefslogtreecommitdiff
path: root/compiler/utils
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2018-11-17 12:31:29 +0100
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>2018-11-17 13:52:26 +0100
commit17e771e17e2374f50f39948955e583760f28351f (patch)
tree7727dae3ef97ceb964b74011f8ff295ca0546fa6 /compiler/utils
parent5bf07866fe34a5b7eb27870ec73a9f44e1c9c37e (diff)
downloadhaskell-17e771e17e2374f50f39948955e583760f28351f.tar.gz
More compact Outputable instance for `Uniq(D)Set`
Summary: Until now, `UniqSet` and `UniqDSet` inherited their `Outputable` instances from `UniqFM` and `UniqDFM`. That made for verbose and redundant output. This patch rectifies that by pretty-printing these sets in common math notation. E.g., previously, we would render `UniqSet`s like this: [s2fE :-> x_s2fE, s2fF :-> y_s2fF, s2fG :-> z_s2fG, s2fH :-> g_s2fH] Now, they're are printed like this: {x_s2fE, y_s2fF, z_s2fG, g_s2fH} Reviewers: simonpj, bgamari, AndreasK, dfeuer, osa1 Reviewed By: osa1 Subscribers: osa1, rwbarton, carter GHC Trac Issues: #15879 Differential Revision: https://phabricator.haskell.org/D5315
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/UniqDSet.hs2
-rw-r--r--compiler/utils/UniqSet.hs4
2 files changed, 4 insertions, 2 deletions
diff --git a/compiler/utils/UniqDSet.hs b/compiler/utils/UniqDSet.hs
index 4be437c1ee..92d924ee37 100644
--- a/compiler/utils/UniqDSet.hs
+++ b/compiler/utils/UniqDSet.hs
@@ -133,4 +133,4 @@ instance Outputable a => Outputable (UniqDSet a) where
ppr = pprUniqDSet ppr
pprUniqDSet :: (a -> SDoc) -> UniqDSet a -> SDoc
-pprUniqDSet f (UniqDSet s) = pprUniqDFM f s
+pprUniqDSet f = braces . pprWithCommas f . uniqDSetToList
diff --git a/compiler/utils/UniqSet.hs b/compiler/utils/UniqSet.hs
index be600a09b3..82b5e9fca4 100644
--- a/compiler/utils/UniqSet.hs
+++ b/compiler/utils/UniqSet.hs
@@ -191,4 +191,6 @@ instance Outputable a => Outputable (UniqSet a) where
ppr = pprUniqSet ppr
pprUniqSet :: (a -> SDoc) -> UniqSet a -> SDoc
-pprUniqSet f (UniqSet s) = pprUniqFM f s
+-- It's OK to use nonDetUFMToList here because we only use it for
+-- pretty-printing.
+pprUniqSet f = braces . pprWithCommas f . nonDetEltsUniqSet