Smarter HsType pretty-print for promoted datacons
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 15 Nov 2018 09:02:11 +0000 (09:02 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 15 Nov 2018 11:50:52 +0000 (11:50 +0000)
commitae2c9b40f5b6bf272251d1f4107c60003f541b62
treeeb786f1cd10c872df876871a44baf7a2ef97abef
parent0ce66be953becf7c9de3cbea406953306b4db3b1
Smarter HsType pretty-print for promoted datacons

Fix Trac #15898, by being smarter about when to print
a space before a promoted data constructor, in a HsType.
I had to implement a mildly tiresome function
    HsType.lhsTypeHasLeadingPromotionQuote
It has multiple cases, of course, but it's very simple.

The patch improves the error-message output in a bunch of
cases, and (to my surprise) actually fixes a bug in the
output of T14343 (Trac #14343), thus

  -  In the expression: _ :: Proxy '('( 'True,  'False),  'False)
  +  In the expression: _ :: Proxy '( '( 'True, 'False), 'False)

I discovered that there were two copies of the PromotionFlag
type (a boolean, with helpfully named data cons), one in
IfaceType and one in HsType.  So I combined into one,
PromotionFlag, and moved it to BasicTypes.  That's why
quite a few files are touched, but it's all routine.
23 files changed:
compiler/basicTypes/BasicTypes.hs
compiler/hsSyn/Convert.hs
compiler/hsSyn/HsTypes.hs
compiler/iface/IfaceType.hs
compiler/iface/TcIface.hs
compiler/iface/ToIface.hs
compiler/parser/Parser.y
compiler/utils/Binary.hs
testsuite/tests/dependent/should_fail/PromotedClass.stderr
testsuite/tests/dependent/should_fail/T15245.stderr
testsuite/tests/ghci/scripts/T15898.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T15898.stdout [new file with mode: 0644]
testsuite/tests/ghci/scripts/all.T
testsuite/tests/parser/should_compile/DumpParsedAst.stderr
testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
testsuite/tests/parser/should_compile/KindSigs.stderr
testsuite/tests/polykinds/PolyKinds07.stderr
testsuite/tests/polykinds/T10503.stderr
testsuite/tests/polykinds/T15116a.stderr
testsuite/tests/polykinds/T7433.stderr
testsuite/tests/printer/T14343.stderr
testsuite/tests/printer/T14343b.stderr
testsuite/tests/typecheck/should_fail/T14607.stderr