The steps and semantics are the same, the only meaningful difference is syntax.

These two definitions are indistinguishable:

f x = y
f = \x -> y

In basically the same way that these two expressions are:

(+) 1 2
1 + 2

In Haskell there are many cases where a more convenient but equivalent syntax exists to express certain terms. This is referred to as syntax sugar.

On Wed, Dec 23, 2020 at 19:12 Lawrence Bottorff <borgauf@gmail.com> wrote:
I have these three versions of addition

addA x y = x + y
addB x = \y -> x + y
addC = \x -> \y -> x + y

and all three add two arguments just fine

> addA 2 3
5
> addB 2 3
5
> addC 2 3
5

but I can't see how addB and addC are actually accomplishing this. addA is currying, which I don't fully follow. addC I understand beta reduction-wise

(\x -> \y -> x + y) 2 3
(\y -> 2 + y) 3
(2 + 3)
5

but I don't understand addB and what steps are happening currying/beta reduction-wise. Can someone break down the steps with addA and addB?

LB


_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners