<div dir="ltr">The report is timing how long a `:load` takes. <div><br></div><div>Sure, if/when I reproduce this on some open source module I'll make a ticket with a test case! <div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 1 December 2017 at 12:03, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-GB" link="blue" vlink="purple">
<div class="m_2796733965689702172WordSection1"><span class="">
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
There does seem to be a significant performance reduction with -fdefer-type-errors:<u></u><u></u></p>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcommercialhaskell%2Fintero%2Fpull%2F495%23issuecomment-348474127&data=02%7C01%7Csimonpj%40microsoft.com%7Cee995eabce464843128408d538b33205%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636477264644187140&sdata=0ZgJ1a56kaIfB9U2vnnf2lIQvP%2BOu26fMnE9sV8xDn4%3D&reserved=0" target="_blank">https://github.com/<wbr>commercialhaskell/intero/pull/<wbr>495#issuecomment-348474127</a><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><u></u> <u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:12.0pt">That’s odd. I would expect zero effect if there aren’t any errors, and not much even if ther are.  It’s not clear whether the report is to do with compile time or runtime.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">If you can boil down a test case, maybe a ticket would be good<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><u></u> <u></u></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">From:</span></b><span lang="EN-US"> Christopher Done [mailto:<a href="mailto:chrisdone@gmail.com" target="_blank">chrisdone@gmail.com</a>]
<br>
<b>Sent:</b> 01 December 2017 12:01<br>
<b>To:</b> Németh Boldizsár <<a href="mailto:nboldi@elte.hu" target="_blank">nboldi@elte.hu</a>><br>
<b>Cc:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>>; <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: GHC typecheck API<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
We're currently experimenting with this for Intero. There does seem to be a significant performance reduction with -fdefer-type-errors:<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcommercialhaskell%2Fintero%2Fpull%2F495%23issuecomment-348474127&data=02%7C01%7Csimonpj%40microsoft.com%7Cee995eabce464843128408d538b33205%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636477264644187140&sdata=0ZgJ1a56kaIfB9U2vnnf2lIQvP%2BOu26fMnE9sV8xDn4%3D&reserved=0" target="_blank">https://github.com/<wbr>commercialhaskell/intero/pull/<wbr>495#issuecomment-348474127</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
It's a classic cost benefit scenario: the benefits are much more type info available, including go to definition and things like that being more immediately up to date. The cost is having to wait more time.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
I believe if there's a good compromise to this, it'll probably involve sometimes enabling -fdefer-type-errors and most of the time turning it off for immediate feedback.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u></u> <u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
On 1 December 2017 at 02:49, Németh Boldizsár <<a href="mailto:nboldi@elte.hu" target="_blank">nboldi@elte.hu</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p>Thank you for the suggestions!<u></u><u></u></p>
<p>Setting the -fdefer-type-errors flag is indeed a good way to do it (with also adding Opt_DeferTypedHoles and Opt_DeferOutOfScopeVariables for other kind of errors).<u></u><u></u></p>
<p><span style="color:#888888">Boldizsár<u></u><u></u></span></p>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">2017.12.01. 4:12 keltezéssel, Christopher Done írta:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">I suppose setting -fdefer-type-errors would also be handy in this scenario!<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, 30 Nov 2017 at 15:37, Simon Peyton Jones via ghc-devs <<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a>> wrote:<u></u><u></u></p>
</div>
<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">This sounds like a good project!<br>
<br>
For the most part things look good:<br>
<br>
* Most type checker errors arise from *type constraints*. The type checkder tries to solve these, but returns an elaborated syntax tree (i.e. typechecked, and annotated with types) even if constraint solving fails.<br>
<br>
* Some renamer errors are like this, notably out-of-scope variables.  (They just show up as another constraint.)<br>
<br>
However there is historical baggage.  Back in the beginning, most errors were treated by throwing an exception in the typechecker monad; such exceptions can be caught, so that we can get more than one error from the file, but no syntax tree is returned.  Example<br>
   let f = <expression> in <body><br>
If there was an error in <expression> we'd throw an exception, catch it at the 'let', give 'f' the type<br>
   f :: forall a. a<br>
and continue to typecheck <body>.<br>
<br>
The trouble with the exception stuff is that you don't get an elaborated syntax tree.<br>
<br>
So: I think you can get some of the way today, just by returning the tree anyway even if there is an error to report.  But it'd take a bit more work to make more and more errors into things that don't throw an exception.  (Look for failTc, failRn in thd code.)<br>
<br>
I'm not very familiar with the GHC API for this part, but others will be.  I'm certain it can be improved, so rather than hacking around what is there already, do propose and implement improvements.<br>
<br>
Simon<br>
<br>
  | -----Original Message-----<br>
| From: ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@<wbr>haskell.org</a>] On Behalf Of Németh<br>
| Boldizsár<br>
| Sent: 30 November 2017 05:42<br>
| To: <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
| Subject: GHC typecheck API<br>
|<br>
| Dear GHC developers,<br>
|<br>
| I'm developing a framework for development tools for Haskell. I use the<br>
| GHC API to parse and typecheck the source files. I recently started to<br>
| work on a quick-fix (automatic program correction) for Haskell source<br>
| code (correcting parenthesis problems, like 'putStrLn "xxx" ++ show a'<br>
| ==> 'putStrLn ("xxx" ++ show a)'). To do that I need to get the typed<br>
| syntax tree even if the program contains type or rename errors. I could<br>
| only do this by a nasty hack, adding a new TH module finalizer<br>
| (tcg_th_modfinalizers) to extract the type checker's state before it<br>
| fails. Is there a "correct" way to do this? I would not like this<br>
| refactorings to be unusable if the GHC API changes.<br>
|<br>
| By the way, if you know of any similar attempt please let me know.<br>
|<br>
| Sincerely,<br>
| Boldizsár Németh<br>
| <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhaskelltools.org&data=02%7C01%7Csimonpj%40microsoft.com%7Cee995eabce464843128408d538b33205%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636477264644187140&sdata=4i0ZmhAEE7BdevNS9u6ij8a3awBsxN4qoqCN1t7BFeU%3D&reserved=0" target="_blank">
haskelltools.org</a><br>
|<br>
| ______________________________<wbr>_________________<br>
| ghc-devs mailing list<br>
| <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
| <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.hask" target="_blank">
https://na01.safelinks.<wbr>protection.outlook.com/?url=<wbr>http%3A%2F%2Fmail.hask</a><br>
| <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fell.org&data=02%7C01%7Csimonpj%40microsoft.com%7Cee995eabce464843128408d538b33205%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636477264644187140&sdata=okocnHpsBzb1HcwAsxsqRBrd4Da9Yyhb0gDh%2BaPGtyw%3D&reserved=0" target="_blank">
ell.org</a>%2Fcgi-bin%2Fmailman%<wbr>2Flistinfo%2Fghc-<br>
| devs&data=02%7C01%7Csimonpj%<a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2F40microsoft.com&data=02%7C01%7Csimonpj%40microsoft.com%7Cee995eabce464843128408d538b33205%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636477264644187140&sdata=nacoOk3PjrNwByq%2FMDcdO6LL0e2AmdpMDZNQjQ70Ugg%3D&reserved=0" target="_blank">40<wbr>microsoft.com</a>%<wbr>7C364b8db55e064415650d08d537b<br>
| 5323f%<wbr>7C72f988bf86f141af91ab2d7cd011<wbr>db47%7C1%7C0%<wbr>7C636476173738772433&sda<br>
| ta=<wbr>Kf5rZYwht8ZGBtGNNH6Q44wLIeefxz<wbr>Hn2UfDIdrNNMU%3D&reserved=0<br>
______________________________<wbr>_________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-devs&data=02%7C01%7Csimonpj%40microsoft.com%7Cee995eabce464843128408d538b33205%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636477264644187140&sdata=42Kc793rTA%2Flz4lpGEafkXVgSEwaHtnlnyoxyW4igtk%3D&reserved=0" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</blockquote>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div>