<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
p.Code, li.Code, div.Code
        {mso-style-name:Code;
        mso-style-link:"Code Char";
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Courier New";}
span.CodeChar
        {mso-style-name:"Code Char";
        mso-style-link:Code;
        font-family:"Courier New";}
span.im
        {mso-style-name:im;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
.MsoPapDefault
        {mso-style-type:export-only;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1985773201;
        mso-list-type:hybrid;
        mso-list-template-ids:-881537070 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
I think this is very similar to what Idris supports for reflecting on errors: <a href="http://www.itu.dk/people/drc/drafts/error-reflection-submission.pdf">http://www.itu.dk/people/drc/drafts/error-reflection-submission.pdf</a><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">Aha!  Yes, thank you for jogging my memory.  I had a good conversation with David Christiansen about this at ICFP, about this very topic, and whether we could steal
 Idris’s clever ideas and put them in GHC.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:Symbol;mso-fareast-language:EN-US"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">He subsequently wrote
<a href="http://www.davidchristiansen.dk/2014/09/06/pretty-printing-idris/">a blog post</a><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:Symbol;mso-fareast-language:EN-US"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">Incidentally, in case it’s not clear
<a href="https://www.haskell.org/pipermail/haskell-cafe/2014-November/117054.html">
this thread on Haskell  Café</a> goes back to Nov 14.  The first message in the series had more useful links<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">David’s idea is would have much broader scope than just TcErrors.  Much of the infrastructure is in place already, since error message are SDocs (an abstract type,
 private to GHC), not strings.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">Design work needed. Start a wiki page.  Articulate a vision.  Discuss alternatives.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US">Simon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Haskell-Cafe [mailto:haskell-cafe-bounces@haskell.org]
<b>On Behalf Of </b>Alejandro Serrano Mena<br>
<b>Sent:</b> 06 February 2015 08:24<br>
<b>To:</b> Adam Gundry<br>
<b>Cc:</b> Haskell Cafe<br>
<b>Subject:</b> Re: [Haskell-cafe] Domain specific error messages<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
I think this is very similar to what Idris supports for reflecting on errors: <a href="http://www.itu.dk/people/drc/drafts/error-reflection-submission.pdf">http://www.itu.dk/people/drc/drafts/error-reflection-submission.pdf</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<o:p> </o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
2015-02-06 8:53 GMT+01:00 Adam Gundry <<a href="mailto:adam@well-typed.com" target="_blank">adam@well-typed.com</a>>:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
[Re-sending to haskell-cafe since I used the wrong From address...]<br>
<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>
> 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>
> (<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">> The game is based on a DSL, it's working well, but at the moment only</span><br>
<span class="im">> expert Haskell developers can play...</span><br>
<span class="im">> I think cryptic error messages is part of the problem.</span><br>
<span class="im">> How to improve that?</span><br>
<span class="im">> For example, a common error message is the following:</span><br>
<span class="im">></span><br>
<span class="im">> Won't Compile</span><br>
<span class="im">> <interactive>:5:28:</span><br>
<span class="im">>     Couldn't match type ‘'NoEffect’ with ‘'Effect’</span><br>
<span class="im">>     Expected type: Exp Effect ()</span><br>
<span class="im">>       Actual type: Exp NoEffect ()</span><br>
<span class="im">>     In the expression: e_1</span><br>
<span class="im">>     In the expression: (let e_1 = do { ... } in e_1) :: Exp Effect ()</span><br>
<span class="im">></span><br>
<span class="im">> It's not so helpful and exposing Nomyx internals.</span><br>
<span class="im">> A better error message would be to hint that the player forgot a "liftEffect" instruction.</span><br>
<span class="im">></span><br>
<span class="im">> The only quick-and-dirty solution I see is to pattern-match for it and display an additional hint line...</span><br>
<br>
<br>
<br>
<span class="hoenzb"><span style="color:#888888">--</span></span><span style="color:#888888"><br>
<span class="hoenzb">Adam Gundry, Haskell Consultant</span><br>
<span class="hoenzb">Well-Typed LLP, <a href="http://www.well-typed.com/" target="_blank">
http://www.well-typed.com/</a></span></span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
_______________________________________________<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><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>