On Mon, 2011-03-14 at 17:56 +0100, Yves Parès wrote: > If you have only one alternative, then you can simply do: > > Opt1 <- someIO > > E.g., if you are _sure_ that foo returns always a 'Just' within a monad you > can perfectly do : > > Just x <- foo >
Please beware - it is not exactly the same as with case if your assumption is wrong: > (do Just x <- return Nothing; [x]) [] > (do x <- return Nothing; case x of Just x -> [x]) *** Exception: <interactive>:1:26-48: Non-exhaustive patterns in case For IO and many monads it is the same but it is not necessary for any monad. Regards _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
