<div dir="ltr">Here's something from <i>Learn You... </i><div><i><br></i></div><div>Lambdas are normally surrounded by parentheses unless we mean for them to extend all the way to the right. Here's something interesting: due to the way functions are curried by default, these two are equivalent:<br><br>addThree :: (Num a) => a -> a -> a -> a  <br>addThree x y z = x + y + z  </div><div><br>addThree :: (Num a) => a -> a -> a -> a  <br>addThree = \x -> \y -> \z -> x + y + z  </div><div><br>If we define a function like this, it's obvious why the type declaration is what it is. There are three ->'s in both the type declaration and the equation. But of course, the first way to write functions is far more readable, the second one is pretty much a gimmick to illustrate currying.<i><br></i></div><div><br></div><div>So with the lambda version how exactly is the currying taking place? I understand something like this</div><div><br></div><div>doubleDouble x = (\x -> x*2) (2 * x)<br></div><div><br></div><div>So with beta reduction we have (2*x)*2, then plug in the argument.</div><div><br></div><div>And with this</div><div><br></div><div>overwrite x = (\x -> (\x -> (\x -> x) 4) 3) 2<br></div><div><br></div><div>which gives (\x -> (\x -> 4) 3) 2</div><div>(\x -> 4) 2</div><div>4</div><div><br></div><div>But how is the beta reduction happening with addThree?</div><div><br></div><div>BTW, I flunked lambda calculus in Kindergarten.</div><div><br></div><div><br></div><div>LB</div><div><br></div></div>