[Haskell-beginners] Monads in javascript

Ertugrul Soeylemez es at ertes.de
Thu Jul 14 11:01:22 CEST 2011


Mats Rauhala <mats.rauhala at gmail.com> wrote:

> I'm trying to grok continuation passing style, but for now it just
> seems to complicate and/or slow down code (stack)

In general CPS will even improve efficiency, in some cases
asymptotically [1,2,3], but that's not their main point.  Delimited
continuations are the mother of all control constructs, so you can
implement many kinds of control flow like concurrency (coroutines),
resumable exceptions (or basic exceptions for that matter), forks and
reunions, etc.

Many Haskell abstractions make use of them; iteratees to name one, on
which I rely heavily.  Also most of the libraries I upload to Hackage
use continuations a lot.

For a web application continuations help a lot with some of the
difficulties of the stateless HTTP, for example form processing and
session management.  Along with every link goes a continuation, which is
the logical future of the computation.  This enables you to write your
web application almost totally disregarding the statelessness, like your
application would talk to a local user on a terminal.  The user session
becomes a coroutine of the web server.

[1] http://www.iai.uni-bonn.de/~jv/mpc08.pdf
[2] http://hackage.haskell.org/package/monad-ran
[3] http://comonad.com/reader/2011/free-monads-for-less/


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110714/b4333c92/attachment.pgp>


More information about the Beginners mailing list