<div dir="ltr"><div>Interesting, in fact I'm surprised error reporting is not already done with some sort of ADT.<br></div>How it is done currently? With string manipulation?<br><div><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 6, 2015 at 8:53 AM, Adam Gundry <span dir="ltr"><<a href="mailto:adam@well-typed.com" target="_blank">adam@well-typed.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[Re-sending to haskell-cafe since I used the wrong From address...]<br>
<div><div class="h5"><br>
This is something that has been on my mind for a while, particularly<br>
following discussions at the last ICFP and prompted by the work on<br>
typechecker plugins in GHC [1]. I think I see a way to proceed, though I<br>
don't know whether I will have time to implement it for a while. I'd be<br>
interested to hear about other approaches.<br>
<br>
Suppose we define an ADT representation of all the typechecker error<br>
messages, e.g. something roughly like<br>
<br>
    data TcError = CustomError String<br>
                 | CouldNotUnify Type Type<br>
                 | NoClassInstance ...<br>
<br>
In GHC all the relevant messages are generated in the<br>
typechecker/TcErrors module, so this shouldn't be too hard to arrange.<br>
Now we can extend plugins with the ability to supply a function<br>
<br>
    tcPluginAdjustErrors :: [TcError] -> TcPluginM [TcError]<br>
<br>
and run the plugged-in function between generating and reporting the<br>
errors. Thus a library defining a DSL could also provide a plugin to<br>
supply more informative error messages.<br>
<br>
This is a fairly quick-and-dirty approach, because the plugin would be<br>
quite tightly coupled to GHC, even though it could be written and<br>
distributed separately. But it might be one way of making progress. (It<br>
also occurs to me that such an ADT might allow GHC to define a<br>
machine-readable serialisable format for its error messages, to allow<br>
post-processing by external programs.)<br>
<br>
Adam<br>
<br>
[1] <a href="https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker</a><br>
<br>
<br>
On 05/02/15 09:54, Corentin Dupont wrote:<br>
</div></div><span class="">> Hi all,<br>
> I have been very interested by this discussion when Alberto started it.<br>
> As there been any progress?<br>
> The problem is very acute in the Nomyx game I'm developing<br>
</span>> (<a href="http://www.nomyx.com" target="_blank">www.nomyx.com</a> <<a href="http://www.nomyx.com" target="_blank">http://www.nomyx.com</a>>).<br>
<span class="im HOEnZb">> The game is based on a DSL, it's working well, but at the moment only<br>
> expert Haskell developers can play...<br>
> I think cryptic error messages is part of the problem.<br>
> How to improve that?<br>
> For example, a common error message is the following:<br>
><br>
> Won't Compile<br>
> <interactive>:5:28:<br>
>     Couldn't match type ‘'NoEffect’ with ‘'Effect’<br>
>     Expected type: Exp Effect ()<br>
>       Actual type: Exp NoEffect ()<br>
>     In the expression: e_1<br>
>     In the expression: (let e_1 = do { ... } in e_1) :: Exp Effect ()<br>
><br>
> It's not so helpful and exposing Nomyx internals.<br>
> A better error message would be to hint that the player forgot a "liftEffect" instruction.<br>
><br>
> The only quick-and-dirty solution I see is to pattern-match for it and display an additional hint line...<br>
<br>
<br>
<br>
</span><span class="HOEnZb"><font color="#888888">--<br>
Adam Gundry, Haskell Consultant<br>
Well-Typed LLP, <a href="http://www.well-typed.com/" target="_blank">http://www.well-typed.com/</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div></div></div></div>