[Haskell-cafe] Question on a common pattern

Yves Parès limestrael at gmail.com
Mon Mar 14 17:56:43 CET 2011


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


2011/3/14 tsuraan <tsuraan at gmail.com>

> In my code, I'm doing this quite a lot:
>
> x <- someIO
> case x of
>  Opt1 -> ...
>
> Having a line for extracting the value from the IO (or STM) and then
> acting on the value seems unnatural.  Is there a more concise way to
> do this?  This code:
>
> case someIO of
>  Opt1 -> ...
>
> Doesn't work, but is there something like that, that is valid?
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110314/efe4eb0b/attachment.htm>


More information about the Haskell-Cafe mailing list