Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-24 Thread Jason Dagit
On 11/23/06, Conor McBride [EMAIL PROTECTED] wrote: *Grr ifM (Just True) (Just 3) Nothing Nothing More care required! Thank you. Now that you point this out I recall that I've made this mistake in the past with (), I once wrote something like liftM2 (). I forget that the liftM* family

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-24 Thread Conor McBride
Jason Dagit wrote: On 11/23/06, Conor McBride [EMAIL PROTECTED] wrote: *Grr ifM (Just True) (Just 3) Nothing Nothing More care required! Thank you. Now that you point this out I recall that I've made this mistake in the past You and me both. It's really insidious and can hide for weeks,

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Jason Dagit
On 11/23/06, Dougal Stanton [EMAIL PROTECTED] wrote: Is there some sort of equivalent of the if/then/else construct for use in the IO monad? For instance the following can get quite tedious: do bool - doesFileExist filename if bool then sth else sth' Is there a more compact way of

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Henk-Jan van Tuyl
You can use 'when' or 'unless' from the module Control.Monad, but they each have only one branch, see: http://members.chello.nl/hjgtuyl/tourdemonad.html#unless and http://members.chello.nl/hjgtuyl/tourdemonad.html#when You can create a monadic 'if' like this (in an interactive session):

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Conor McBride
Jason Dagit wrote: On 11/23/06, Dougal Stanton [EMAIL PROTECTED] wrote: Is there some sort of equivalent of the if/then/else construct for use in the IO monad? For instance the following can get quite tedious: do bool - doesFileExist filename if bool then sth else sth' Is there a

Re: [Haskell-cafe] Equivalent of if/then/else for IO Bool?

2006-11-23 Thread Luis F. Araujo
Dougal Stanton wrote: Is there some sort of equivalent of the if/then/else construct for use in the IO monad? For instance the following can get quite tedious: do bool - doesFileExist filename if bool then sth else sth' Is there a more compact way of writing that?