
Antoine Latter
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
Yeah, that's a great functional CPS-based goto, which allows all kinds of spaghetti code. And it is in fact a real jump because of tail-call optimization. =) As a side note, the 'abort' function is implemented in a similar way. It ignores the continuation and jumps to an empty computation, that way it returns from the ContT computation. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/