<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">We could always make a hyperlink to the source code as hosted on GitLab. But I actually argue not to: such links would quickly become outdated, in one of two ways: either we make a permalink, in which case the linked Note text will become outdated; or we make a link to a particular file & line, in which case the Note might move somewhere else. Instead, just by naming the Note title, we have a slightly-harder-to-use link, where you use it by grepping the source code. This is less convenient, but it will stay up-to-date. Until we have better tooling to, say, create an HTML anchor based on a Note, I think this is the best we can do.<div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 28, 2021, at 12:10 PM, Benjamin Redelings <<a href="mailto:benjamin.redelings@gmail.com" class="">benjamin.redelings@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">I was thinking about the relationship between the wiki and the notes in the GHC source.</p><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Would it be possible to link directly to [compiler notes] in the GHC source from the wiki, using hyperlinks? Right now, I'm seeing references that look like: (See<span class="Apple-converted-space"> </span><code class="">Note [Constraint flavours]</code>.)</p><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">(I can see the motivation to include comments in the source, but I also think that the wiki is more discoverable than the compiler source code. So, in the interests of pursuing both approaches, it would be nice to be able to link to notes FROM the wiki. I suppose one could include a hyperlink to the file on github that contains the note...)</p><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">I'm not sure how much web infrastructure would be required to make hyperlinks for notes...<br class=""></p><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">-BenRI<br class=""></p><div class="moz-cite-prefix" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">On 11/8/21 5:35 AM, Simon Peyton Jones wrote:<br class=""></div><blockquote type="cite" cite="mid:AM9PR83MB0483BB7F13B5B4A0D5ED9E16AD919@AM9PR83MB0483.EURPRD83.prod.outlook.com" style="font-family: Helvetica; font-size: 14px; 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-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="WordSection1" style="page: WordSection1;"><p style="margin-left: 36pt;" class="">Is there anywhere on the GHC wiki that explains how to interpret this output, and says that the type and dictionary applications ARE there, just not shown by '-ddump-tc'?<o:p class=""></o:p></p><p style="margin-left: 36pt;" class="">Perhaps it would be helpful to add some basic description of what comes out of the typechecker to a page like this one? (below)<o:p class=""></o:p></p><p style="margin-left: 36pt;" class=""> <span class="Apple-converted-space"> </span><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.haskell.org%2Fghc%2Fghc%2F-%2Fwikis%2Fcommentary%2Fcompiler%2Fhsc-main&data=04%7C01%7Csimonpj%40microsoft.com%7Cab59b17d2f394945ad1e08d9a2b96c81%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637719740212483767%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=WZL1VADZPUlaOACd58K1XZO5MzPOKrfLFMSuBD%2FGW44%3D&reserved=0" moz-do-not-send="true" style="color: blue; text-decoration: underline;" class="">https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/hsc-main</a><o:p class=""></o:p></p><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="">Yes it would! Would you care to start such a wiki page (a new one; don’t just clutter up the one you point to)? You can write down what you know. Don’t worry if you aren’t 100% sure – we can correct it. And if you outright don’t know, leave a “What should I say here?” note.<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class=""><o:p class=""> </o:p></span></div><p style="margin-left: 36pt;" class="">"This late desugaring is somewhat unusual. It is much more common to desugar the program before typechecking, or renaming, because that presents the renamer and typechecker with a much smaller language to deal with. However, GHC's organisation means that<o:p class=""></o:p></p><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="">This note is now slightly out of date. We are now, very carefully, doing some desugaring<span class="Apple-converted-space"> </span><b class="">before</b><span class="Apple-converted-space"> </span>typechecking. See<o:p class=""></o:p></span></div><ul type="disc" style="margin-bottom: 0cm; margin-top: 0cm;" class=""><li class="MsoListParagraph" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span class="">Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr<o:p class=""></o:p></span></li><li class="MsoListParagraph" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span class="">Note [Rebindable syntax and HsExpansion] in GHC.Hs.Expr<o:p class=""></o:p></span></li></ul><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="">You can and should point to these and similar Notes from the wiki page you write. Indeed there may be some part of what you write that would be better framed as Note in GHC’s source code.<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="">Thanks!<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="">Simon<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 8pt;" class="">PS: I am leaving Microsoft at the end of November 2021, at which point<span class="Apple-converted-space"> </span><a href="mailto:simonpj@microsoft.com" moz-do-not-send="true" style="color: blue; text-decoration: underline;" class=""><span style="color: rgb(5, 99, 193);" class="">simonpj@microsoft.com</span></a><span class="Apple-converted-space"> </span>will cease to work. Use<span class="Apple-converted-space"> </span><a href="mailto:simon.peytonjones@gmail.com" moz-do-not-send="true" style="color: blue; text-decoration: underline;" class=""><span style="color: rgb(5, 99, 193);" class="">simon.peytonjones@gmail.com</span></a><span class="Apple-converted-space"> </span>instead. (For now, it just forwards to<span class="Apple-converted-space"> </span><a class="moz-txt-link-abbreviated" href="mailto:simonpj@microsoft.com" style="color: blue; text-decoration: underline;">simonpj@microsoft.com</a>.)<o:p class=""></o:p></span></div></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class=""><o:p class=""> </o:p></span></div><div style="border-style: none none none solid; border-left-width: 1.5pt; border-left-color: blue; padding: 0cm 0cm 0cm 4pt;" class=""><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""><span class="Apple-converted-space"> </span>ghc-devs<span class="Apple-converted-space"> </span><a class="moz-txt-link-rfc2396E" href="mailto:ghc-devs-bounces@haskell.org" style="color: blue; text-decoration: underline;"><ghc-devs-bounces@haskell.org></a><span class="Apple-converted-space"> </span><b class="">On Behalf Of<span class="Apple-converted-space"> </span></b>Benjamin Redelings<br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>08 November 2021 13:12<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Richard Eisenberg<span class="Apple-converted-space"> </span><a class="moz-txt-link-rfc2396E" href="mailto:lists@richarde.dev" style="color: blue; text-decoration: underline;"><lists@richarde.dev></a><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a class="moz-txt-link-abbreviated" href="mailto:ghc-devs@haskell.org" style="color: blue; text-decoration: underline;">ghc-devs@haskell.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: Output language of typechecking pass?<o:p class=""></o:p></span></div></div></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><p class="">Hi,<o:p class=""></o:p></p><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">Questions:<o:p class=""></o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">1. It seems like this separation is actually necessary, in order to apply generalization only to let arguments written by the programmer, and not to let bindings introduced during desugaring. Is that right?<o:p class=""></o:p></pre></blockquote><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">I don't think so. That is, if we did it all in one pass, I still think we could get generalization right.<o:p class=""></o:p></pre></blockquote><p class="">I guess I asked this question wrong. I mean to say, if we did the two passes in the reverse order (desugaring first, followed by typechecking), that would not work, right?<o:p class=""></o:p></p><p class="">As the wiki says:<o:p class=""></o:p></p><p class="">"This late desugaring is somewhat unusual. It is much more common to desugar the program before typechecking, or renaming, because that presents the renamer and typechecker with a much smaller language to deal with. However, GHC's organisation means that<o:p class=""></o:p></p><ul type="disc" style="margin-bottom: 0cm;" class=""><li class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">error messages can display precisely the syntax that the user wrote; and<o:p class=""></o:p></li><li class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">desugaring is not required to preserve type-inference properties.<o:p class=""></o:p></li></ul><p class="">"<o:p class=""></o:p></p><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">2. Does the output of type checking contain type lambdas?<o:p class=""></o:p></pre></blockquote><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">Yes. See below.<o:p class=""></o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">3. Does the type checking pass determine where to add dictionary arguments?<o:p class=""></o:p></pre></blockquote><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">Yes. See below.<o:p class=""></o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">4. Are there any other resources I should be looking at?<o:p class=""></o:p></pre></blockquote><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">Yes. You want to enable -fprint-typechecker-elaboration (and possible -fprint-explicit-coercions). With the former, you get to see all this stuff you're looking for. It's normally suppressed so that the output resembles the user's code.<o:p class=""></o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">I hope this helps!<o:p class=""></o:p></pre><pre style="margin: 0cm; font-size: 10pt; font-family: "Courier New";" class="">Richard<o:p class=""></o:p></pre></blockquote><p class="">Hmm... so, I think I see how this works now. I don't think '-fprint-explicit-coercions' does anything here though.<o:p class=""></o:p></p><p class="">$ ghc -ddump-tc Test2.hs -fprint-typechecker-elaboration<o:p class=""></o:p></p><p class="">...<o:p class=""></o:p></p><p class="">AbsBinds [a_a2hp] [$dNum_a2hB]<br class=""> <span class="Apple-converted-space"> </span>{Exports: [g <= g_a2hz<br class=""> <span class="Apple-converted-space"> </span>wrap: <>]<br class=""> <span class="Apple-converted-space"> </span>Exported types: g :: forall a. Num a => a -> a -> a<br class=""> <span class="Apple-converted-space"> </span>[LclId]<br class=""> <span class="Apple-converted-space"> </span>Binds: g x_aYk y_aYl = (y_aYl * x_aYk) + 1<br class=""> <span class="Apple-converted-space"> </span>Evidence: [EvBinds{[W] $dNum_a2hs = $dNum_a2hq<br class=""> <span class="Apple-converted-space"> </span>[W] $dNum_a2hw = $dNum_a2hq<br class=""> <span class="Apple-converted-space"> </span>[W] $dNum_a2hq = $dNum_a2hB}]}<o:p class=""></o:p></p><p class="">...<o:p class=""></o:p></p><p class="">The type and dictionary arguments are visible here (along with the evidence bindings), but type and dictionary applications are only visible if you use -ddump-tc-ast, which is a lot more verbose. (I don't think there is another flag that shows these applications?) Since I didn't initially know what "evidence" was, and there is nothing to say that a_a2hp is a type lambda argument, this was pretty opaque until I managed to read the tc-ast and the light went on.<o:p class=""></o:p></p><p class="">I can see now that the type and dictionary arguments are added by annotating the AST.<o:p class=""></o:p></p><p class="">Is there anywhere on the GHC wiki that explains how to interpret this output, and says that the type and dictionary applications ARE there, just not shown by '-ddump-tc'?<o:p class=""></o:p></p><p class="">Perhaps it would be helpful to add some basic description of what comes out of the typechecker to a page like this one? (below)<o:p class=""></o:p></p><p class=""> <span class="Apple-converted-space"> </span><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.haskell.org%2Fghc%2Fghc%2F-%2Fwikis%2Fcommentary%2Fcompiler%2Fhsc-main&data=04%7C01%7Csimonpj%40microsoft.com%7Cab59b17d2f394945ad1e08d9a2b96c81%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637719740212483767%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=WZL1VADZPUlaOACd58K1XZO5MzPOKrfLFMSuBD%2FGW44%3D&reserved=0" moz-do-not-send="true" style="color: blue; text-decoration: underline;" class="">https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/hsc-main</a><o:p class=""></o:p></p><p class="">-BenRI</p></div></div></blockquote></div></blockquote></div><br class=""></div></body></html>