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? Something akin to: > > > condM (doesFileExist filename) (sth) (sth')
I'd suggest cond t f True = t cond t f False = f and then you use it like doesFileExist filename >>= cond sth sth' I find it strange that we have 'maybe' for 'Maybe', 'either' for 'Either', 'foldr' for '[]', but a special syntactic form for 'Bool'. Why is there no 'cond' in the Prelude? -Udo -- There is no snooze button on a cat who wants breakfast.
signature.asc
Description: Digital signature
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
