
#8809: Prettier error messages? -------------------------------------+------------------------------------- Reporter: joelteon | Owner: (none) 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: 13122 Related Tickets: | Differential Rev(s): #8809,#10073,#10179,#12906,#13670 | Wiki Page: | -------------------------------------+------------------------------------- @@ -0,0 +1,2 @@ + [wiki:PrettyErrors] is a wiki page summarising the state of play. + New description: [wiki:PrettyErrors] is a wiki page summarising the state of play. `clang` has very nice-looking error messages. {{{ #!html <pre><span style="font-weight: bold">pretty.c:6:7: <span style="color: pink">warning:</span> incompatible pointer to integer conversion passing 'char [14]' to parameter of type 'int' [-Wint-conversion]</span> foo("Hello, world!"); <span style="color: green">^~~~~~~~~~~~~~~</span> <span style="font-weight: bold">pretty.c:1:14: note: passing argument to parameter 'i' here</span> void foo(int i) { <span style="color: green">^</span> 1 warning generated.</pre> }}} `ghc`'s error messages are not so good. {{{ #!html <pre>ugly.hs:7:18: Couldn't match expected type ‘()’ with actual type ‘[Char]’ In the first argument of ‘f’, namely ‘"Hello, world!"’ In the second argument of ‘($)’, namely ‘f "Hello, world!"’ In the expression: print $ f "Hello, world!"</pre> }}} In my opinion, there are three independent improvements that could be made to GHC error messages and warnings: color, context and whitespace. Currently they're blobs of text. Consider all three applied to error messages: {{{ #!html <pre><strong>ugly.hs:7:18: <span style="color: red">error:</span> Argument to 'f' is type '[Char]' but expected 'Int'</strong> main = print $ f "Hello, world!" <span style="color: green">^~~~~~~~~~~~~~~</span> <strong>ugly.hs:3:1: note: type of 'f' is given here:</strong> f :: () -> IO () <span style="color: green">^~</span></pre> }}} or {{{ #!html <pre><strong>ugly.hs: note: type of 'f' is inferred:</strong> f :: forall m. Monad m => () -> m () <span style="color: green">^~</span></pre> }}} In my opinion, context and whitespace are more important that color. Even without color, compare this error message to the one shown above: {{{ ugly.hs:7:18: error: Argument to 'f' is type '[Char]' but expected 'Int' main = print $ f "Hello, world!" ^~~~~~~~~~~~~~~ ugly.hs:3:1: note: type of 'f' is given here: f :: () -> IO () ^~ }}} In my opinion this is much easier to visually process than GHC's current messages. -- Comment (by simonpj): [wiki:PrettyErrors] is a wiki page summarising the state of play. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8809#comment:72 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler