More compact Outputable instance for `Uniq(D)Set`
ClosedPublic

Authored by sgraf on Nov 9 2018, 9:53 AM.

Details

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 UniqSets 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}

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sgraf created this revision.Nov 9 2018, 9:53 AM
sgraf edited the summary of this revision. (Show Details)Nov 9 2018, 11:55 AM
osa1 added a subscriber: osa1.Nov 11 2018, 11:16 PM

Could you add an example of how this was printed previously and how it's printed now, in the summary?

sgraf edited the summary of this revision. (Show Details)Nov 13 2018, 9:00 AM
sgraf edited the summary of this revision. (Show Details)

Of course. I realised that we ''might'' want to consider sticking to brackets instead of braces, but on the other hand this would severely clash with how lists are formatted.

In D5315#146815, @sgraf wrote:

Of course. I realised that we ''might'' want to consider sticking to brackets instead of braces, but on the other hand this would severely clash with how lists are formatted.

There is plenty of Haskell precedent for things like "fromList [1,2,3]", but for a pretty printer some style of curly brackets seems better. Unless there's some likely source of confusion, you should be able to stick with what you have.

osa1 accepted this revision.Nov 16 2018, 6:19 AM

@dfeuer any objections to merging this?

This revision is now accepted and ready to land.Nov 16 2018, 6:19 AM
This revision was automatically updated to reflect the committed changes.