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. Closure clear-up? (Galaxy Being) ---------------------------------------------------------------------- Message: 1 Date: Fri, 26 Feb 2021 12:28:30 -0600 From: Galaxy Being <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Closure clear-up? Message-ID: <CAFAhFSXLe++27tBS85s1j6Mbx1W=5XbdPtb=ya818xxckvu...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" >From my moving-target understanding of closures, I'm guessing this has a closure let succ = add 1 add x = xadder where xadder y = x + y in succ 3 Now, can someone explain in words how the closure system is at work here? I see that the add 1 is being "baked in". Do we say this is a closure on add 1? (Closure wording is confusing.) The enclosing scope of add contains 1; however, xadder is what succ ultimately becomes, which has 1 in its scope in that when xadder is defined, the x argument will be the 1 of add 1. Or am I missing something? Researching closures vis-a-vis Haskell, I've seen the argument that, - no, Haskell doesn't have closures, - yes, Haskell is lazy, *everything* can be seen as a closure, as even a value can be seen as a function without argument waiting to be evaluated (and so capturing its environment until it gets evaluated). This was taken from an older Haskell textbook (*Introduction to Functional Programming Systems Using Haskell *by Davie). LB -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210226/6d251e48/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 151, Issue 13 ******************************************