Hello Günther, I use ContT monads for early exit often, because that's one of the things they encode naturally. But I don't do this with callCC. I prefer monadLib over mtl/transformers, which has a specific function for that:
abort :: (AbortM m i) => i -> m a where AbortM is a class for monads, whose computations are abortable. All ContT monads are instances. This is also a nice way to break out of 'forever'. Using an error monad (like Maybe) may be more natural of course. Greets, Ertugrul Günther Schmidt <[email protected]> wrote: > Hi everyone, > > I'm about to write a rather lengthy piece of IO code. Depending on the > results of some of the IO actions I'd like the computation to stop right > there and then. > > Now I know in general how to write this but I'm wondering if this is one > of those occasions where I should make use of the Cont monad to make an > early exit. > > Günther -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
