<div>Please correct me if I&#39;m wrong in any of the reasoning below.</div><div><br></div>Haskell provides the ability the perform partial application on the rightmost arguments.<div><br></div><div>I learned from some pretty smart guys that partial application cannot be emulated with lambas, because they behave differently operationally,&nbsp;e.g.</div>
<div><br></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">e = trace &quot;e&quot;</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">op = (+)</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;"><br></span></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">a1 = let f = (op (e 1)) in (f 10, f 100)<br>
</span></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">a2 = let f = (\x -&gt; op (e 1) x) in (f 10, f 100)</span></div><div><br></div><div>a1 and a2 are operationally not the same: a1 will evaluate (e 1) once, a2 will evaluate it twice.&nbsp;</div>
<div><br></div><div>However, Haskell also allows to partially apply the second argument of binary functions (using sections)<br></div><div><br></div><div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;">b1 = let f = (`op` (e 1)) in (f 10, f 100)</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;">b2 = let f = (\x -&gt; (e 1) `op` x) in (f 10, f 100)</span></div><div><br></div></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;"><span class="Apple-style-span" style="font-family: arial; font-size: 13px; "><div>
Again, b1 evaluates (e 1) once, b2 twice.</div><div><br></div><div>b1 is actually the same as</div><div><br></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px; ">c1 = let f = ((flip op) (e 1)) in (f 10, f 100)<br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; font-size: 12px;"><br></span></div><div><div>So for ternary functions we could write more permutations of flip:</div><div><br></div>
<div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; ">flip3_12 f a1 a2 a3 = f a2 a1 a3</span><br></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;;"><div>flip3_13 f a1 a2 a3 = f a3 a2 a1</div>
<div>flip3_23 f a1 a2 a3 = f a1 a3 a2</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial; "><div>And use these to partially apply any argument&nbsp;</div><div><br></div></span></div></span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; ">e1 x = trace &quot;e1&quot; x</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; ">e2 x = trace &quot;e2&quot; x</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; "><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; ">op2 :: Int -&gt; Int -&gt; Int -&gt; Int</span><br>
</div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; ">op2 x y z = x+10*y+100*z</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;; "><br></span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">z1 = let f = (flip3_12 op2) (e1 1) (e2 2) in (f 3, f 4)</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">z2 = let f = (flip3_13 op2) (e1 1) (e2 2) in (f 3, f 4)</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">z3 = let f = (flip3_23 op2) (e1 1) (e2 2) in (f 3, f 4)</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;;"><span class="Apple-style-span" style="font-family: arial; "><div>This could be extended to N-ary functions. Haskell doesn&#39;t give any special syntactic support for this, but it surely is possible.</div>
<div><br></div><div>Am I missing something here? Is there any easier way to perform &quot;generalized partial application&quot;?<br></div><div><br></div><div><br></div></span></span></div><div><br></div></div></div></div>
</span></span></div></div></div></div></div>