Explanation: FP Lambda calculus - Haskell

I suck at these kind of things, I am currently reading Haskell Programming - From first principles, it’s a great book but I don’t really get the Lambda calculus, maybe I have to wait a bit more to understand it better.

I would love if any of you lads could take a few minutes and explain it to me.
Thanks!

3 Likes

I can’t explain it well enough to help you, but I am more than halfway through that book and I’m doing great without being an expert at LC, so don’t sweat it.

Here’s a classic talk that touches on some concepts: https://www.youtube.com/watch?v=FITJMJjASUs

1 Like

What do you think about it so far? At first I thought that it’s a bit expensive but for the amount of content, and good reviews it had, I couldn’t stop myself from buying it. I don’t regret it so far.

It’s probably the best language learning book I’ve read. It’s well written, has a great flow of subjects, and most importantly: TONS of exercises. Too many developers think they can learn by just reading. Doing reading and exercises daily helps so much! Stick with it and enjoy it!

2 Likes

When I was learning I found the lambda calculus reduction workbench helpful. Starting out I recommend playing around with several expressions in normal evaluation order with tracing on. Some good examples to start:

No reduction cases

  • variables: x ==> x
  • variable x applied to variable y: x y ==> x y
  • abstraction (lambda) without application: \x.y ==> \x.y

Simple reduction cases

  • abstraction with application: (\x.y) z ==> y
  • the identity function applied to z: (\x.x) z ==> z
  • eta-conversion: \x.(\y.z) x ==> \y.z

That last one is evaluated by the workbench to \x.z instead of \y.z, but they’re equivalent because when applied to anything they both reduce to z. I use \y.z here because it’s makes the eta-conversion step clearer. Renaming that results in no behavioral change is called alpha-conversion. The first two reduction examples, where abstractions were applied to other expressions, are called beta-reduction.

Next steps

Even after understanding how to formulate and evaluate LC expressions it may not be clear why LC is useful. To understand that, I recommend studying Church encoding and fixed-point combinators. Once that’s clear you’ll realize how you could use a machine like the LC reduction workbench for arbitrary computation.

3 Likes

I don’t understand how somebody could simply learn just by reading, getting your hands dirty is what does the most for me. Having the code in my hands and being able to play with it is what makes learning fun.

Thanks so much for the explanation and links, really helpful!

1 Like

Like others have noted in this thread, teaching LC in an answer is not feasible. Maybe you could ask a question and get back a Just Answer (see what I did here? If not, wait till you hit the “Signalling adversity” chapter).

At any rate, you don’t have to know or even understand LC, nor category theory, nor math for that matter to be competent, at the very least, at Haskell.
And for reaching that goal, “…from first principles” is pretty much the best resource you can get your hands on. Personally I ditched “Learn you…”, a great resource in and of itself, in favor of “First”.

1 Like

Welcome to the club :slight_smile:

My material for haskell

if you have some questions about book you can ask on
https://www.reddit.com/r/HaskellBook/

Some my code, but not so much so far

1 Like

Another helpful starting point is the recent Computerphile video on LC.

4 Likes

That nails how brutally simple LC is.

3 Likes