Prettier error messages?
PrettyErrors is a wiki page summarising the state of play.
clang
has very nice-looking error messages.
<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.
<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:
<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
ugly.hs: note: type of 'f' is inferred:
f :: forall m. Monad m => () -> m ()
^~
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.