Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  A one- or two-page diagram of how Haskell    works?
      (Anthony Clayden)


----------------------------------------------------------------------

Message: 1
Date: Fri, 17 Sep 2021 10:00:18 +1200
From: Anthony Clayden <anthony.d.clay...@gmail.com>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] A one- or two-page diagram of how
        Haskell works?
Message-ID:
        <cabu_mxi9p8fpfx2aoroxqsvhmsbw0hc-zo1fdapr309+cuy...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Thank you Tarik, you're spot-on correct.

> It's better to try to model execution using lambda calculus.

> The most dominant factor in languages like Haskell is lambda calculus.
> Think through lambda calculus for a mental model.


I presume it's this advice that Michael is complaining about in his
long comment on the cafe yesterday.

In particular, Haskell is unusual even amongst functional programming
languages in its lazy evaluation. So to try to correct Michael's
misunderstanding:


>> When I write C, or even C++, I have a mental model of how execution will 
>> proceed.


Firstly, 'execution' in Haskell does not proceed in anything like the
sequence-of-steps and update-of-locations/frame-on-the-stack of C or C++
(or Fortran or ALGOL or COBOL or ...). In particular, 'variables' in
Haskell are not overwritable locations in the sense of a procedural
language. Variables are just a name for an expression (might be a lambda
expression). This is what we mean by 'referential transparency' that
procedural languages do not have. We can replace any variable by the
expression it denotes, or by any other equivalent expression.

Secondly, there's an important theorem (Church-Rosser) in Lambda calculus
[see wikipedia], that if Beta-reduction terminates, it'll produce the same
'reduced form' of the initial expression whether it proceeds inside-out or
outside-in or both-sides-to-the-middle. You don't need to second-guess how
the compiler proceeds, because you don't need to know.

You do need to understand Beta-reduction (that's easy). You also need to
understand why Alpha-renaming is needed hand-in-hand with Beta-reduction
(not so easy, but work a few examples with a recursive function, such as
stepping through a list).

And you need to stop immediately trying to imagine Haskell semantics as
some sort of crazy Turing machine: you'll go mad. Turing himself [1937]
proved the semantics are equivalent; but that paper is impenetrable for
ordinary mortals like me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20210917/fc368093/attachment-0001.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of Beginners Digest, Vol 158, Issue 3
*****************************************

Reply via email to