diff options
author | Michał Sośnicki <sosnicki.michal@gmail.com> | 2015-11-18 16:02:53 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-18 17:31:20 +0100 |
commit | c61759d5917996a10b06a286eb5b776e4069e35c (patch) | |
tree | 7fc3b9a29cec4f98e28278d23e5000743d0d3956 /compiler/utils/Outputable.hs | |
parent | 07eb258dfcbf8a67e4e931397128b7255356d19e (diff) | |
download | haskell-c61759d5917996a10b06a286eb5b776e4069e35c.tar.gz |
Fix inconsistent pretty-printing of type families
After the changes, the three functions used to print type families
were identical, so they are refactored into one.
Original RHSs of data instance declarations are recreated and
printed in user error messages.
RHSs containing representation TyCons are printed in the
Coercion Axioms section in a typechecker dump.
Add vbar to the list of SDocs exported by Outputable.
Replace all text "|" docs with it.
Fixes #10839
Reviewers: goldfire, jstolarek, austin, bgamari
Reviewed By: jstolarek
Subscribers: jstolarek, thomie
Differential Revision: https://phabricator.haskell.org/D1441
GHC Trac Issues: #10839
Diffstat (limited to 'compiler/utils/Outputable.hs')
-rw-r--r-- | compiler/utils/Outputable.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index 83febd5d04..fbd6760923 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -25,7 +25,7 @@ module Outputable ( int, intWithCommas, integer, float, double, rational, parens, cparen, brackets, braces, quotes, quote, doubleQuotes, angleBrackets, paBrackets, - semi, comma, colon, dcolon, space, equals, dot, + semi, comma, colon, dcolon, space, equals, dot, vbar, arrow, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt, lparen, rparen, lbrack, rbrack, lbrace, rbrace, underscore, blankLine, forAllLit, @@ -33,7 +33,7 @@ module Outputable ( ($$), ($+$), vcat, sep, cat, fsep, fcat, - hang, punctuate, ppWhen, ppUnless, + hang, hangNotEmpty, punctuate, ppWhen, ppUnless, speakNth, speakN, speakNOf, plural, isOrAre, doOrDoes, coloured, PprColour, colType, colCoerc, colDataCon, @@ -521,7 +521,7 @@ quotes d = ('\'' : _, _) -> pp_d _other -> Pretty.quotes pp_d -semi, comma, colon, equals, space, dcolon, underscore, dot :: SDoc +semi, comma, colon, equals, space, dcolon, underscore, dot, vbar :: SDoc arrow, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt :: SDoc lparen, rparen, lbrack, rbrack, lbrace, rbrace, blankLine :: SDoc @@ -541,6 +541,7 @@ equals = docToSDoc $ Pretty.equals space = docToSDoc $ Pretty.space underscore = char '_' dot = char '.' +vbar = char '|' lparen = docToSDoc $ Pretty.lparen rparen = docToSDoc $ Pretty.rparen lbrack = docToSDoc $ Pretty.lbrack @@ -606,6 +607,12 @@ hang :: SDoc -- ^ The header -> SDoc hang d1 n d2 = SDoc $ \sty -> Pretty.hang (runSDoc d1 sty) n (runSDoc d2 sty) +-- | This behaves like 'hang', but does not indent the second document +-- when the header is empty. +hangNotEmpty :: SDoc -> Int -> SDoc -> SDoc +hangNotEmpty d1 n d2 = + SDoc $ \sty -> Pretty.hangNotEmpty (runSDoc d1 sty) n (runSDoc d2 sty) + punctuate :: SDoc -- ^ The punctuation -> [SDoc] -- ^ The list that will have punctuation added between every adjacent pair of elements -> [SDoc] -- ^ Punctuated list |