<div dir="ltr">Try `Control.Monad.void`. It is equivalent of adding `>> return ()` to the end of a block.<div><br></div><div>void $ do</div><div> ...</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 9 June 2015 at 20:55, Vale Cofer-Shabica <span dir="ltr"><<a href="mailto:vale.cofershabica@gmail.com" target="_blank">vale.cofershabica@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br>
<br>
I'm writing a command line program which may need to exit early based<br>
on some condition. Because of the pipeline the program is a part of, I<br>
want to be able to control the exit status when it does terminate. I<br>
can successfully use 'error' to indicate failure, but also want to<br>
exit early with success (or any other status). Here's what I've<br>
managed:<br>
<br>
>import System.Exit (exitSuccess)<br>
>import Control.Monad (when)<br>
<br>
>main = do<br>
<br>
... code to reasonably initialize condition, e.g.:<br>
<br>
>  let condition = True<br>
>  when condition (putStrLn "Bailing out.")>>exitSuccess>>(return ())<br>
<br>
... program continues<br>
<br>
If I remove ">>(return ())" my code will not typecheck because<br>
"exitSuccess :: IO a". But this looks ugly and smells sufficiently<br>
like a kludge that I presume there is a better way to do it.<br>
<br>
Any suggestions appreciated,<br>
vale<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div>