[Haskell-cafe] Re: ANNOUNCE: GotoT-transformers version 1.0

Antoine Latter aslatter at gmail.com
Thu Sep 9 01:21:50 EDT 2010

On Wed, Sep 8, 2010 at 11:54 PM, Ertugrul Soeylemez <es at ertes.de> wrote:
> Gregory Crosswhite <gcross at phys.washington.edu> wrote:
>>  On 09/08/10 19:14, Ertugrul Soeylemez wrote:
>> > Have you looked at ContT from monadLib?  It's not just a goto, but
>> > in fact a setjmp/longjmp, i.e. a goto with value.  I haven't used it
>> > for anything yet, but it might come in handy for some algorithms:
>> >
>> > [...]
>> Whoa, that's cool!  I glanced at monadLib but I didn't realize that it
>> let you create labels that you could return to like that.  :-) (I know
>> of callCC, but that isn't quite the same as this.)  Thanks for the
>> pointer!
> It is, in fact, callCC. ;)
>> The limitation with continuation-based approaches to goto, though, is
>> that you can only jump back to points that you've seen before.  The
>> reason why I don't use a continuation-based approach in GotoT is
>> because I wanted the user (i.e., me, and maybe one or two other people
>> if I'm lucky :-) ) to be able to jump to an arbitrary point outside
>> the calculation that has never been visited before, rather than
>> returning a previously visited point of the same calculation.
>> Of course, if someone can prove to me that I am wrong and that GotoT
>> semantics can be implemented with continuations, then I would welcome
>> this information.  :-)
> I don't think you need 'goto' to implement jumps in Haskell.  Note that
> functions as well as computations are first class:

To recover from my overly complex previous post, here is a much simply
goto based on existing monad transformers:

> goto :: Monad m => ContT r m r -> ContT r m a
> goto (ContT m) = ContT $ \_ ->
>                m return

Reading your post, Ertugrul, made something click for me


More information about the Haskell-Cafe mailing list