<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think the accumulator should not be named &#39;r&#39; because there are many result types in the List module that are not named &#39;r&#39; and should not be, for instance because argument and result have the same type or are just Int or Bool.</blockquote>

<div><br></div><div>I agree that many result types in the List module should not be named &#39;r&#39;. I therefore suggest that the convention be used only in cases like &quot;foldr&quot; where there are *two or more type variables*, and we can benefit from more clearly distinguishing one from the others. The current convention seems to be left-to-right a-thru-z, which as the foldr vs foldl issue illustrates, is suboptimal.</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The distinguishing feature of a result type is that it is the last type in a chain of arrows, but you can hardly express this using the variable name.<br>


</blockquote></div><br><div>Ah, but this is precisely why I personally do use the &quot;r&quot; convention: because anywhere in the type signature where I see an &quot;r&quot;, I know that it must match with the &quot;result&quot; type (the one at the end of the chain of arrows). I believe I picked up the &quot;r&quot; convention from Control.Monad.Cont, or possibly from Data.Conduit. This is what &quot;r&quot; means to me, and I think it is a convention worth pushing onto everyone else. ;)</div>

<div><br></div><div>After looking over the type signatures of Data.List, I propose the following &quot;rule of thumb&quot;:</div><div><br></div><div>When the final result type (the one at the end of a chain of arrows)</div>

<div>of a function is a single polymorphic type with no additional structure (e.g. just &quot;a&quot; not &quot;[a]&quot; or &quot;Maybe a&quot;),</div><div>and the type signature of the function involves more than one type variable,</div>

<div>then the type variable appearing in the final position should be &quot;r&quot;.</div><div>(If there is just one type variable, then it should be &quot;a&quot;)</div><div><br></div><div>According to this rule of thumb,</div>

<div>only the following changes would be made:</div><div><br></div><div>foldl :: (r -&gt; a -&gt; r) -&gt; r -&gt; [a] -&gt; r</div><div>foldl&#39; :: (r -&gt; a -&gt; r) -&gt; r -&gt; [a] -&gt; r</div><div>foldr :: (a -&gt; r -&gt; r) -&gt; r -&gt; [a] -&gt; r</div>

<div><br></div><div>Technically this means that the &quot;genericBlah&quot; functions should also change,</div><div>but those have a special case of their own, which is that the integral should be &quot;i&quot;.</div><div>

Oddly, this convention is not followed consistently, so while we&#39;re alpha-renaming,</div><div>might I also suggest that we make the genericBlah docs consistent</div><div>by using &quot;i&quot; for the integral, and &quot;a&quot; for the list member.</div>

<div>(e.g. &quot;genericIndex :: Integral i =&gt; [a] -&gt; i -&gt; a&quot;)</div><div><br></div><div>Another potential reason to dislike this proposal is that</div><div>GHCi will not follow this convention, and thus</div>

<div>will not suggest the same type signature.</div><div>(Although it could be made to, since I believe I have</div><div>specified a precise algorithm.)</div><div><br></div><div>-- Dan Burton</div>