Tuesday, October 2, 2012

Yet another good use of delimited continuation

Scope herding with delimited continuations

One confusing aspect to the continuation discussion is that in Scheme (where continuation got its start) future of computation is what is to the left of the shift. For instance in (reset (foo (bar ( shift....)))) the bar and foo functions are the rest of the computation after the shift (thus the context that is passed to the shift function). Whereas in Haskell's do notation we have

shift $ do
.....
shift ( some function here )
bar
foo

Here the rest of the continuation (the bar, and foo) are what follows the shift to the end of the do block. Seems more intuitive, doesn't it?

Friday, March 16, 2012

Tutorial on Continuation and Delimited Continuation

A nice tutorial on Continuation and delimited Continuation here.

Wednesday, January 4, 2012

I like this post on what monadic parsers are and where they are useful.

This exchange further explains when you need monadic power.

....use the simplest tool which gets the job done. Don't use a fork lift when a dolly will do. Don't use a table saw to cut out coupons. Don't write code in IO when it could be pure. Keep it simple.

But sometimes, you need the extra power of Monad. A sure sign of this is when you need to change the course of the computation based on what has been computed so far. In parsing terms, this means determining how to parse what comes next based on what has been parsed so far; in other words you can construct context-sensitive grammars this way.