<span style="color:rgb(34,34,34);font-family:arial,sans-serif">(I&#39;m again starting a new thread to focus on this issue. It&#39;s easier to track that way.)</span><br><br><div class="gmail_quote">
On Thu, Oct 4, 2012 at 11:40 AM, Simon Peyton-Jones 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><div>
<p class="MsoNormal" style="margin-left:36.0pt">There is also the small matter, in this example, of distinguishing which `_&#39; is which. The description works, but you have to think about it. I don&#39;t have an immediate and simple solution to this. Perhaps the
 addition of unique labels (e.g. _$1 _$2). But this is not a major problem. It can even wait until some future development/expansion on TypeHoles.</p></div></div></div></blockquote><div><br></div><div>Just to clarify the &quot;small matter&quot; above, I was proposing a way to reference unnamed holes in the warning messages. This was only to solve the relatively minor problem of visually distinguishing the holes if there are multiple.</div>

<div><br></div><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><p class="MsoNormal" style="margin-left:36.0pt"><u></u><u></u></p>


<p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:Verdana,sans-serif">I have a proposal.  Someone has already suggested on </span><a href="http://hackage.haskell.org/trac/ghc/ticket/5910" target="_blank" style="font-family:Verdana,sans-serif">hackage.haskell.org/trac/ghc/ticket/5910</a><span style="color:rgb(31,73,125);font-family:Verdana,sans-serif"> that an un-bound variable behaves like a hole.  Thus, if you say</span></p>

</div>



<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">          f x = y<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">GHC says “Error: y is not in scope”.  But (idea) with -XTypeHoles<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">f x = y<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">might generate
<u></u><u></u></span></p>
<p><u></u><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)"><span>1.<span style="font-style:normal;font-variant:normal;font-weight:normal;line-height:normal;font-family:&#39;Times New Roman&#39;">  
</span></span></span><u></u><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">(renamer)
<b>Warning</b>: y is not in scope<u></u><u></u></span></p>
<p><u></u><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)"><span>2.<span style="font-style:normal;font-variant:normal;font-weight:normal;line-height:normal;font-family:&#39;Times New Roman&#39;">  
</span></span></span><u></u><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">(type)
<b>Error</b>: Hole “y” has type....<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">So that’s like a named hole, in effect.   
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">If you say<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">   f x = 4<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">GHC warns about the unused binding for x.  But if you say<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">   f _x = 4<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">the unused-binding warning is suppressed.  So (idea) if you say<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">          f x = _y<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">maybe we can suppress warning (1).  And, voila, named holes.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">Moreover if you add –fdefer-type-errors you can keep going and run the program.<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif;color:rgb(31,73,125)">Any comments?  This is pretty easy to do.</span></p></div></blockquote><div><br></div><div>I also like the proposal; however, I think it only makes sense if the set of unbound variables with the same name is treated as referring to the same identifier. This was, after all, the main reason for named holes. Roman expected this, and I think everybody who uses the feature will expect it.</div>

<div><br></div><div><div class="gmail_quote">On Fri, Oct 5, 2012 at 9:24 AM, Roman Cheplyaka wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

* Roman Cheplyaka [2012-10-05 10:22:23+0300]<br><div><div class="h5">&gt; * Simon Peyton-Jones [2012-10-05 07:14:36+0000]<br>&gt; &gt; | Sounds cool. I would also expect that if you have several occurences of<br>&gt; &gt; | the same unbound identifier, then it gets a unified type.<br>

&gt; &gt;<br>&gt; &gt; I thought about this, but I think not. Consider<br>&gt; &gt;<br>&gt; &gt; f x1 = _y<br>&gt; &gt; g x2 = _y<br>&gt; &gt;<br>&gt; &gt; Do you want _y and _y to be unified, so that f and g are no longer polymorphic?  I think not.  Any more than the &quot;_&quot; holes we have now are unified.<br>

&gt;<br>&gt; Do you mean polymorphism in their argument? Why would it go away?<br>&gt;<br>&gt; I would expect the functions to get types `a -&gt; c` and `b -&gt; c`<br>&gt; respectively, and `c` to be reported as the type of the hole.<br>

<br></div></div>Ah, I see. Since `c` is universally quantified, it means different<br>things for f and g. Good point.<br></blockquote></div></div><div><br></div><div>I would expect `_y&#39; to be unified. I&#39;m not sure how to write the type of `f&#39; or `g&#39; (maybe `forall a. a -&gt; c&#39; and `forall b. b -&gt; c&#39;?), but I would still expect `_y&#39; to have some type `c&#39;. It would be endlessly confusing to have identifiers that look the same but aren&#39;t.</div>

<div><br></div><div>Here&#39;s a thought that just occurred to me, though I&#39;m not yet sure if it makes sense. Treat all expression identifiers _x as unique but report them as one hole with all possible types. Then, you can visually identify the patterns between the types. So:</div>

<div><br></div><div>&gt; f x = _y</div><div>&gt; g x = _y &#39;a&#39;</div><div><br></div><div>with some warning like this:</div><div><br></div><div>    Found hole `_y&#39; in multiple locations with the possible types</div>

<div>    File.hs:##:##:  a0</div><div>    File.hs:##:##:  Char -&gt; b0</div><div><br></div><div>Now, I know by looking at it that `a0&#39; and `b0&#39; are universally quantified per location, but I can do some mental unification myself.</div>

<div><br></div><div>Regards,</div><div>Sean</div><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></blockquote></div>