Hi,<br><br><div>Looking at the source of Data.Foldable I found something I don&#39;t understand</div><div><br></div><div>The Foldable class declares foldl like this:<br><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre>

<span class="hs-comment" style="color: green; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; white-space: normal; "><pre><span class="hs-varid">foldl</span> <span class="hs-keyglyph" style="color: red; ">::</span> <span class="hs-layout" style="color: red; ">(</span><span class="hs-varid">a</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">b</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">a</span><span class="hs-layout" style="color: red; ">)</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">a</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">t</span> <span class="hs-varid">b</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">a</span></pre>

<pre><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial; font-size: small; white-space: normal; ">Them, outside of the class, foldr&#39; is defined like this:</span></pre>

</span></span></pre></span><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre><span class="hs-comment" style="color: green; ">-- | Fold over the elements of a structure,</span>
<a name="line-170"></a><span class="hs-comment" style="color: green; ">-- associating to the right, but strictly.</span>
<a name="line-171"></a><span class="hs-definition">foldr&#39;</span> <span class="hs-keyglyph" style="color: red; ">::</span> <span class="hs-conid">Foldable</span> <span class="hs-varid">t</span> <span class="hs-keyglyph" style="color: red; ">=&gt;</span> <span class="hs-layout" style="color: red; ">(</span><span class="hs-varid">a</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">b</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">b</span><span class="hs-layout" style="color: red; ">)</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">b</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">t</span> <span class="hs-varid">a</span> <span class="hs-keyglyph" style="color: red; ">-&gt;</span> <span class="hs-varid">b</span>
<a name="line-172"></a><span class="hs-definition">foldr&#39;</span> <span class="hs-varid">f</span> <span class="hs-varid">z0</span> <span class="hs-varid">xs</span> <span class="hs-keyglyph" style="color: red; ">=</span> <span class="hs-varid">foldl</span> <span class="hs-varid">f&#39;</span> <span class="hs-varid">id</span> <span class="hs-varid">xs</span> <span class="hs-varid">z0</span>
<a name="line-173"></a>  <span class="hs-keyword" style="color: blue; ">where</span> <span class="hs-varid">f&#39;</span> <span class="hs-varid">k</span> <span class="hs-varid">x</span> <span class="hs-varid">z</span> <span class="hs-keyglyph" style="color: red; ">=</span> <span class="hs-varid">k</span> <span class="hs-varop">$!</span> <span class="hs-varid">f</span> <span class="hs-varid">x</span> <span class="hs-varid">z</span></pre>

</span><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><pre><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal;">I don&#39;t understand this definition, foldl receives 3 parameters and here it is used with 4, how is it possible?</span></font></pre>

<pre style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; white-space: normal; ">Even the function passed to foldl has 3 parameters when a function of 2 is needed.</span></pre>

<pre style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><span class="Apple-style-span" style="font-family: arial; font-size: small; white-space: normal; ">What is the precedence and associativity involved here that makes foldr&#39; a valid expression?</span></pre>

<pre><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal;">Thanks!</span></font></pre></div><br>--<br>Federico Mastellone<br>Computer Science Engineer - ITBA<br>&quot;.. there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.&quot;<br>

<br>Tony Hoare, 1980 ACM Turing Award Lecture.<br><br></div>