<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Simon,</div><div class=""><br class=""></div><div class="">I suppose this is possible, but it would change lots of error messages. (Currently, the uo_thing -- when reported -- is included inline with other parts of the message.) In my opinion, if we're going to reformat error messages, we could do better than this, anyway. I'm thinking of something like</div><div class=""><br class=""></div><div class="">Type mismatch error:</div><div class=""> `uo_thing` has one type, but I expected a different type.</div><div class=""> type of `uo_thing`: `actual`</div><div class=""> expected type: `expected`</div><div class=""><br class=""></div><div class="">where `expected` and `actual` are vertically aligned, as they are today. (This would require the ability to query the rendered length of an SDoc, which is not currently possible... but I don't think would be all that hard, as long as we were in a context that returned an SDoc.) What I like about this formatting is that it puts `uo_thing` right at the top of the error; this is the chunk of user-written syntax that causes the error.</div><div class=""><br class=""></div><div class="">I've not tried this yet because I haven't the time to sift through the thousand error-message changes that this would cause.</div><div class=""><br class=""></div><div class="">Putting uo_thing in the ErrCtxt would make something like this impossible, I think.</div><div class=""><br class=""></div><div class="">Richard</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 21, 2017, at 3:50 AM, Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" class="">simonpj@microsoft.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">Richard<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">I’m on a train, so can’t look at the detail. But the following thought occurs to me.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">uo_thing is a Maybe SDoc attached to a constraint. But a constraint also has a stack of [ErrCtxt], captured in the CtLoc. That’s what produces the “In the declaration for …” stuff.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">Idea: instead of uo_thing, could we just push an extra ErrCtxt onto the stack, in the CtLoc for this constraint? (Or not, in the Nothing case.)<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">Simon<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><a name="_MailEndCompose" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></a></div><span class=""></span><div style="border-style: none none none solid; border-left-color: blue; border-left-width: 1.5pt; padding: 0cm 0cm 0cm 4pt;" class=""><div class=""><div style="border-style: solid none none; border-top-color: rgb(225, 225, 225); border-top-width: 1pt; padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><b class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="Apple-converted-space"> </span><a href="mailto:noreply@phabricator.haskell.org" class="">noreply@phabricator.haskell.org</a> [<a href="mailto:noreply@phabricator.haskell.org" class="">mailto:noreply@phabricator.haskell.org</a>]<span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>18 July 2017 19:39<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" class="">simonpj@microsoft.com</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>[Differential] [Request, 533 lines] D3754: Refactor uo_thing<o:p class=""></o:p></span></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div><table class="MsoNormalTable" border="0" cellspacing="5" cellpadding="0"><tbody class=""><tr class=""><td style="padding: 0.75pt;" class=""><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif;">goldfire created this revision.<br class="">Herald added subscribers: thomie, rwbarton.<br class="">Herald added a reviewer: hvr.<span class="Apple-converted-space"> </span><o:p class=""></o:p></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><a href="https://phabricator.haskell.org/D3754" style="color: purple; text-decoration: underline;" class=""><b class=""><span style="color: rgb(70, 76, 92); background-color: rgb(247, 247, 249); text-decoration: none; background-position: initial initial; background-repeat: initial initial;" class="">View Revision</span></b></a><o:p class=""></o:p></div></td></tr></tbody></table><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></p><div class=""><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">REVISION SUMMARY</span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></span></p><div class=""><p class="">The uo_thing field of TypeEqOrigin is used to track the<br class="">"thing" (either term or type) that has the type (kind) stored<br class="">in the TypeEqOrigin fields. Previously, this was sometimes a<br class="">proper Core Type, which needed zonking and tidying. Now, it<br class="">is only HsSyn: much simpler, and the error messages now use<br class="">the user-written syntax.<o:p class=""></o:p></p><p class="">But this aspect of uo_thing didn't cause<span class="Apple-converted-space"> </span><a href="https://ghc.haskell.org/trac/ghc/ticket/13819" style="color: purple; text-decoration: underline;" class=""><b class="">Trac #13819</b></a>; it was the<br class="">sibling field uo_arity that did. uo_arity stored the number<br class="">of arguments of uo_thing, useful when reporting something<br class="">like "should have written 2 fewer arguments". We wouldn't want<br class="">to say that if the thing didn't have two arguments. However,<br class="">in practice, GHC was getting this wrong, and this message<br class="">didn't seem all that helpful. Furthermore, the calculation<br class="">of the number of arguments is what caused<span class="Apple-converted-space"> </span><a href="https://ghc.haskell.org/trac/ghc/ticket/13819" style="color: purple; text-decoration: underline;" class=""><b class="">Trac #13819</b></a><span class="Apple-converted-space"> </span>to fall over.<br class="">This patch just removes uo_arity. In my opinion, the change<br class="">to error messages is a nudge in the right direction.<o:p class=""></o:p></p><p class="">Test case: typecheck/should_fail/T13819<o:p class=""></o:p></p></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">TEST PLAN</span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></span></div><div class=""><p class="">./validate<o:p class=""></o:p></p></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">REPOSITORY</span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></span></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">rGHC Glasgow Haskell Compiler<o:p class=""></o:p></span></div></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">BRANCH</span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></span></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">wip/rae<o:p class=""></o:p></span></div></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">REVISION DETAIL</span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><a href="https://phabricator.haskell.org/D3754" style="color: purple; text-decoration: underline;" class="">https://phabricator.haskell.org/D3754</a><o:p class=""></o:p></span></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">AFFECTED FILES</span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></span></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">compiler/ghci/RtClosureInspect.hs<br class="">compiler/typecheck/Inst.hs<br class="">compiler/typecheck/TcArrows.hs<br class="">compiler/typecheck/TcErrors.hs<br class="">compiler/typecheck/TcExpr.hs<br class="">compiler/typecheck/TcHsType.hs<br class="">compiler/typecheck/TcMType.hs<br class="">compiler/typecheck/TcPat.hs<br class="">compiler/typecheck/TcRnTypes.hs<br class="">compiler/typecheck/TcSigs.hs<br class="">compiler/typecheck/TcSplice.hs<br class="">compiler/typecheck/TcSplice.hs-boot<br class="">compiler/typecheck/TcTyClsDecls.hs<br class="">compiler/typecheck/TcType.hs<br class="">compiler/typecheck/TcUnify.hs<br class="">compiler/typecheck/TcUnify.hs-boot<br class="">compiler/types/Type.hs<br class="">testsuite/tests/indexed-types/should_fail/T12867.stderr<br class="">testsuite/tests/polykinds/T12593.stderr<br class="">testsuite/tests/polykinds/T6039.stderr<br class="">testsuite/tests/polykinds/T7278.stderr<br class="">testsuite/tests/polykinds/T8616.stderr<br class="">testsuite/tests/polykinds/T9200b.stderr<br class="">testsuite/tests/rename/should_fail/rnfail026.stderr<br class="">testsuite/tests/th/T3177a.stderr<br class="">testsuite/tests/typecheck/should_fail/T11356.stderr<br class="">testsuite/tests/typecheck/should_fail/T11672.stderr<br class="">testsuite/tests/typecheck/should_fail/T12785b.stderr<br class="">testsuite/tests/typecheck/should_fail/T13819.hs<br class="">testsuite/tests/typecheck/should_fail/T13819.stderr<br class="">testsuite/tests/typecheck/should_fail/T2994.stderr<br class="">testsuite/tests/typecheck/should_fail/T3540.stderr<br class="">testsuite/tests/typecheck/should_fail/T4875.stderr<br class="">testsuite/tests/typecheck/should_fail/T7609.stderr<br class="">testsuite/tests/typecheck/should_fail/T7778.stderr<br class="">testsuite/tests/typecheck/should_fail/all.T<br class="">testsuite/tests/typecheck/should_fail/tcfail070.stderr<br class="">testsuite/tests/typecheck/should_fail/tcfail078.stderr<br class="">testsuite/tests/typecheck/should_fail/tcfail113.stderr<br class="">testsuite/tests/typecheck/should_fail/tcfail123.stderr<br class="">testsuite/tests/typecheck/should_fail/tcfail132.stderr<o:p class=""></o:p></span></div></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">EMAIL PREFERENCES</span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><a href="https://phabricator.haskell.org/settings/panel/emailpreferences/" style="color: purple; text-decoration: underline;" class="">https://phabricator.haskell.org/settings/panel/emailpreferences/</a><o:p class=""></o:p></span></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><strong class=""><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">To:<span class="Apple-converted-space"> </span></span></strong><span style="font-size: 10pt; font-family: Calibri, sans-serif;" class="">goldfire, simonpj, austin, bgamari, hvr<br class=""><strong class=""><span style="font-family: Calibri, sans-serif;" class="">Cc:<span class="Apple-converted-space"> </span></span></strong>rwbarton, thomie, Mikolaj, fryguybob, carter, mpickering, adamgundry</span></div></div></div></div></div></blockquote></div><br class=""></body></html>