[Haskell-cafe] Improving ghc error messages

José Pedro Magalhães jpm at cs.uu.nl
Thu Sep 18 07:42:03 UTC 2014


On Thu, Sep 18, 2014 at 8:13 AM, Toby Goodwin <toby at paccrat.org> wrote:

> Interesting article:
> https://izbicki.me/blog/error-messages-in-ghc-vs-g++.html
>
> I do hope some of these changes make it into a future ghc. I'd
> particularly like to highlight this one:
>
>     No instance for (Show ([a0] -> Int)) arising from a use of `show'
>     Possible fix: add an instance declaration for (Show ([a0] -> Int))
>
> The second line looks like it was added by someone who'd read an article
> about making error messages helpful: "suggest a possible way to fix the
> error". Like creating a Show instance for a function type!?!
>

That's a bit unfair. The second line does add a valuable tip in many cases,
because often you might indeed just have forgotten to give an instance.

That being said, the error reporting mechanism could use a bit of tweaking
when it comes to the Show class and the function type, because:
1) Show is used all the time (namely in ghci), and
2) Functions are very often involved in newbie errors (such as forgetting
to supply an argument to a function, or doing things like |map(succ
[1,2,3])|.


Cheers,
Pedro


>
> I must have seen that "possible fix" 1000 times, and 999 of them it was
> nothing like the right fix. Now I know just to ignore it. Simply removing
> the second line would be an improvement: it doesn't add anything to the
> first line.
>
> Toby.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140918/efb97431/attachment.html>


More information about the Haskell-Cafe mailing list