[Haskell-cafe] Re: Control.Monad.Cont fun

Magnus Carlsson magnus at carlssonia.org
Sun Jul 17 17:36:33 EDT 2005


Tomasz Zielonka wrote:
> On Fri, Jul 15, 2005 at 11:51:59PM +0200, Magnus Carlsson wrote:
> 
>>A while ago, I attempted to marry value recursion a la Levent Erkök with
>>the continuation-monad transformer.  It seems possible if the underlying
>>monad has value recursion and references.  Interestingly, all mfix
>>properties except left shrinking appear to be valid.
>>
>>There are slides about this (including implementation) at
>>
>>  http://www.cse.ogi.edu/~magnus/mdo-callcc-slides.pdf
>>
>>There is also a draft paper at
>>
>>  http://www.cse.ogi.edu/~magnus/mdo-callcc.pdf
> 
> 
> I've already found your paper and played with the implementation :-)

:-)

> I was stupid to think that with MonadCont+MonadFix+getCC it would be
> possible to do forward jumps, but of course it doesn't work because of
> the strictness law.

I would expect forward jumps to work.  For example, consider

    callcc (\k -> mfix (\v -> E))

where we assume that E is an expression in which k and v are free.

Then it would be OK for E to invoke k and thereby jump "forward".  In
this case, the recursive value (bound to v) is simply bottom.

Moreover, suppose E in turn captures the current continuation and gives
it as an argument to k.  Then, it is possible to jump back inside E
again at a later point.  E might in this case return a non-bottom value,
which also would be the value of v.

Cheers,
Magnus


More information about the Haskell-Cafe mailing list