Or what about a specialized Escape Continuation monad? (Perhaps there is one on hackage, not sure).<br><br>Something that allows you to set up an continuation (for "escape") purposes, but does not allow you<br>to capture any more continuations after that, and call that escape cont w/in itself, supplying a "return" value.<br>
<br>i.e. <br><br>> run = do<br>> result <- createEscape $ \escape -><br>> lengthyComputation1<br>> inp <- askToContinue<br>> if (not (continue inp)) <br>> then escape "They quit"<br>
> else lengthyComputation2<br>> return result<br><br>Just thinking off the top of my head :).<br><br>However, if there are going to be multiple 'lengthy computations' then perhaps<br>MaybeT or EitherT would be better, b/c they allow the propagation of failure<br>
across multiple actions, instead of cascading off to the right of the screen w/ 'if's or 'case's.<br><br>Cheers,<br> - Tim<br><br><div class="gmail_quote">On Thu, Jun 10, 2010 at 3:21 PM, Ben Millwood <span dir="ltr"><<a href="mailto:haskell@benmachine.co.uk">haskell@benmachine.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On Thu, Jun 10, 2010 at 8:57 PM, Maciej Piechotka <<a href="mailto:uzytkownik2@gmail.com">uzytkownik2@gmail.com</a>> wrote:<br>
><br>
</div><div class="im">> Error monad seems not to be a semantic solution as we exit on success<br>
> not failure.<br>
><br>
<br>
</div>Which is really why the Either monad should not necessarily have Error<br>
associations :)<br>
If you forget about the fail method, the Monad (Either e) instance<br>
doesn't need the e to be an error type.<br>
<br>
Alternatively, if even Error is more information than you need, you<br>
could use MaybeT:<br>
<br>
<a href="http://hackage.haskell.org/package/MaybeT" target="_blank">http://hackage.haskell.org/package/MaybeT</a><br>
<br>
which allows you to just stop. Given you're using it with IO it'd be<br>
easy to write a result to an IORef before terminating the computation,<br>
so it's of equivalent power, if slightly less convenient.<br>
<div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>