The idea is the same as Show's showList method. With this we render
String as an actual string rather than a list of chars.
- rGHC Glasgow Haskell Compiler
No Unit Test Coverage
- Build Status
Buildable 22980 Build 54245: [GHC] Linux/amd64: Continuous Integration Build 54244: [GHC] OSX/amd64: Continuous Integration Build 54243: [GHC] Windows/amd64: Continuous Integration Build 54242: arc lint + arc unit
It's not obvious to me that we should render a String like this in Outputable, after all we don't render a FastString with double quotes, and we don't render a Char with single quotes. Outputable is not intended to produce Haskell concrete syntax, it's mainly for pretty-printing the various internal compiler data structures.
Yes, I'm not very bothered that ppr "foo" prints ['f', 'o', 'o']. I believe that getting nicer output in this one case is what motivates the patch (though you do not express a clear motivation).
I'd be inclined not to do this; we can just write text "foo" instead.
But perhaps you have a strong motivation?
The use case is when I have a String in a larger type, e.g. Maybe [String]. Now I want to pprDebug this, but by default it gives me bad output because string is rendered as a list of characters. I could try fmap (map text) x but that would not work because we don't have Outputable instance for SDoc (that is D2761). For the same reason text "..." also doesn't work (you may get an unrenderable type, e.g. Just [text "..."] is not renderable).
Even with D2761 these are more work than just doing ppr.
As for how to render String: I think it's fine as long as we don't render as a list of chars, which is completely unreadable and takes too much space.
It just means that every Outputable dictionary is now a boxed pair rather than a simple function. Maybe that doesn't matter.
GHC doesn't have many Strings anyway.
It's not a huge deal of course.
I wonder if anyone else cares? Ask ghc-devs and point them to this patch?