[GHC] #8809: Prettier error messages?

GHC ghc-devs at haskell.org
Fri Dec 9 20:10:14 UTC 2016


#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.9
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
  #8809,#10073,#10179,#12906         |
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Rufflewind):

 Here's a sketch of [https://phabricator.haskell.org/D2718 what the caret
 diagnostics look like now]:

 {{{
 #!html
 <code>
 <pre><span style="font-weight:
 bold">testsuite/tests/warnings/should_fail/CaretDiagnostics1.hs:8:31:
 <span style="color: red">error</span>:
     • Couldn't match expected type ‘[Char]’ with actual type ‘()’
     • In the second argument of ‘(+)’, namely ‘()’
       In the first argument of ‘pure’, namely
         ‘("this is not an IO" + ())’
       In a stmt of a 'do' block: pure ("this is not an IO" + ())</span>

   pure ("this is not an IO" + <span style="color: red; font-weight:
 bold">(            )</span>)
                               <span style="color: red; font-weight:
 bold">^^^^^^^^^^^^^^</span>

 <span style="font-weight:
 bold">testsuite/tests/warnings/should_fail/CaretDiagnostics1.hs:13:7:
 error:
     • Couldn't match expected type ...</span></pre></code>
 }}}

 There are some minor tweaks to the style I mentioned previously: the
 underlining is now the same color as the error type (red = error, magenta
 = warning) and the underlined part of the code is also colored and bolded.
 It also uses exclusively carets (no more tildes).  There is also an empty
 line separating the error message itself from the caret diagnostic.

 I could go even further to add a margin, kind of like Rust:

 {{{
 #!html
 <code>
 <pre><span style="font-weight:
 bold">testsuite/tests/warnings/should_fail/CaretDiagnostics1.hs:8:31:
 <span style="color: red">error</span>:
     • Couldn't match expected type ‘[Char]’ with actual type ‘()’
     • In the second argument of ‘(+)’, namely ‘()’
       In the first argument of ‘pure’, namely
         ‘("this is not an IO" + ())’
       In a stmt of a 'do' block: pure ("this is not an IO" + ())</span>
   <span style="color: blue">|</span>
 <span style="color: blue">8 |</span>   pure ("this is not an IO" + <span
 style="color: red; font-weight: bold">(            )</span>)
   <span style="color: blue">|</span>                               <span
 style="color: red; font-weight: bold">^^^^^^^^^^^^^^</span>

 <span style="font-weight:
 bold">testsuite/tests/warnings/should_fail/CaretDiagnostics1.hs:13:7:
 error:
     • Couldn't match expected type ...</span></pre></code>
 }}}

 but I'm concerned that (a) it might add more noise to the diagnostics; (b)
 it loses the nice property that if your source code is ≤ 80 characters,
 the error message is guaranteed to be also ≤ 80 characters (otherwise, if
 the user's terminal is too small, the messages will wrap and become
 misaligned).

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:42>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list