Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Continuations (Joel Neely)
2. Re: Continuations (Shishir Srivastava)
3. ANNOUNCE: Haskell Communities and Activities Report (28th
ed., May 2015) (Mihai Maruseac)
----------------------------------------------------------------------
Message: 1
Date: Fri, 29 May 2015 07:15:27 -0500
From: Joel Neely <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Continuations
Message-ID:
<caeezxaj78q2lzrirfn5mnvvrlmug9rp2pjq8jyv1w3u90zp...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Shishir,
You've already gotten some excellent descriptions.
As a recovering OO programmer, I get to the same answer by a slightly
different path, offered below for what it's worth.
When I read the first line:
let add_cps x y = \k -> k (x+y)
I see a definition of a function (add_cps) with two arguments (x and y)
whose evaluation yields a function (\k -> k (x+y)).
*I started to write "an anonymous function" out of habit, but stopped
myself. I don't think of functions as having names or not having names, any
more than I think of expressions as having names or not. Variables are
bound to (refer to) values, and a function is just another kind of value to
which a variable can refer. (And multiple variables can refer to the same
value, by the way, so none of them is really "the name" of the value,
regardless of whether that value happens to be a function.)*
So at this point, I can think of using the name add_cps in another
expression, such as:
add_cps 3 4
which (by the substitution principle) must be equivalent to:
\k -> k (3+4)
That expression is clearly a function (because of the lambda) that takes a
single argument and applies it to the expression (3+4) (which isn't yet
evaluated, by the way, but when it is I expect it to yield 7). So the
argument to that function expression must itself be a function.
When I get to the second line:
add_cps 3 4 $ print
I confess to cheating a bit (and the experts may want to offer me some
correction). I mentally rewrite that as:
(add_cps 3 4) print
because the precedence rules tell me to evaluate the left argument of $ before
combining that with what follows.
So I can apply the substitution principle to get
(\k -> k (3+4)) print
and then apply it again to get
print (3+4)
Hope this helps,
-jn-
On Thu, May 28, 2015 at 8:57 AM, Shishir Srivastava <
[email protected]> wrote:
> Hi,
>
> Reading on continuation I've came across this new style of creating the
> functions which I guess is not very clear in how it works
>
> ---------------
> Prelude> let add_cps x y = \k -> k (x+y)
> Prelude> add_cps 3 4 $ print
> 7
> ---------------
>
> I have some questions as to
> 1) what is the role of variable 'k' and what eventually happens to it.
> 2) How does print work after the $ because there is clearly no parameter
> being passed to it.
>
> Thanks,
> Shishir Srivastava
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
--
Beauty of style and harmony and grace and good rhythm depend on simplicity.
- Plato
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150529/2c5022f3/attachment-0001.html>
------------------------------
Message: 2
Date: Fri, 29 May 2015 13:26:13 +0100
From: Shishir Srivastava <[email protected]>
To: beginners <[email protected]>, [email protected]
Subject: Re: [Haskell-beginners] Continuations
Message-ID:
<CALe5RTu2BLNHKw7xyLFGAbfuP3zeR+NuVuSxSTWUTog_gTq=0...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi Amy
Thanks for explanation. Yes I can now see that equivalence relation between
your example and mine. It does sometime feel alien to see variables
representing partially applied functions (e.g k in this case) when you are
coming from the imperative land.
Cheers,
Shishir Srivastava
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150529/0b77c0ae/attachment-0001.html>
------------------------------
Message: 3
Date: Fri, 29 May 2015 16:41:56 -0400
From: Mihai Maruseac <[email protected]>
To: Haskell <[email protected]>, haskell <[email protected]>,
Haskell Beginners <[email protected]>, Lista principala
<[email protected]>
Subject: [Haskell-beginners] ANNOUNCE: Haskell Communities and
Activities Report (28th ed., May 2015)
Message-ID:
<CAOMsUMKiKjR5LcodFXK_LctiTszo=8jhbiii7zkp9omtney...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On behalf of all the contributors, we are pleased to announce that the
Haskell Communities and Activities Report
(28th edition, May 2014)
is now available, in PDF and HTML formats:
http://haskell.org/communities/05-2015/report.pdf
http://haskell.org/communities/05-2015/html/report.html
Many thanks go to all the people that contributed to this report,
both directly, by sending in descriptions, and indirectly, by doing
all the interesting things that are reported. We hope you will find
it as interesting a read as we did.
If you have not encountered the Haskell Communities and Activities
Reports before, you may like to know that the first of these reports
was published in November 2001. Their goal is to improve the
communication between the increasingly diverse groups, projects, and
individuals working on, with, or inspired by Haskell. The idea behind
these reports is simple:
Every six months, a call goes out to all of you enjoying Haskell to
contribute brief summaries of your own area of work. Many of you
respond (eagerly, unprompted, and sometimes in time for the actual
deadline) to the call. The editors collect all the contributions
into a single report and feed that back to the community.
When we try for the next update, six months from now, you might want
to report on your own work, project, research area or group as well.
So, please put the following into your diaries now:
========================================
End of September 2015:
target deadline for contributions to the
November 2015 edition of the HC&A Report
========================================
Unfortunately, many Haskellers working on interesting projects are so
busy with their work that they seem to have lost the time to follow
the Haskell related mailing lists and newsgroups, and have trouble even
finding time to report on their work. If you are a member, user or
friend of a project so burdened, please find someone willing to make
time to report and ask them to "register" with the editors for a simple
e-mail reminder in October (you could point us to them as well, and we
can then politely ask if they want to contribute, but it might work
better if you do the initial asking). Of course, they will still have to
find the ten to fifteen minutes to draw up their report, but maybe we
can increase our coverage of all that is going on in the community.
Feel free to circulate this announcement further in order to
reach people who might otherwise not see it. Enjoy!
Mihai Maruseac and Alejandro Serrano Mena
<hcar at haskell.org>
--
Mihai Maruseac (MM)
"If you can't solve a problem, then there's an easier problem you can
solve: find it." -- George Polya
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150529/ac98105b/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 83, Issue 59
*****************************************