
Good call. I see `orM` is actually a wrapper of the "ugly" nested-if. So operators can be another wrapper away. Thanks. On Mon, May 27, 2019 at 3:35 PM Emil Axelsson <78emil@gmail.com> wrote:
Not with the standard `||` and `&&` operations. You'd have to define new versions with a `Monad` constraint.
The `monad-loops` package is pretty nice for short-circuiting stuff. See, for example, `andM` and `orM`. But it doesn't provide any binary operators.
https://hackage.haskell.org/package/monad-loops
/ Emil
Den 2019-05-27 kl. 07:07, skrev Magicloud Magiclouds:
Hi,
I think `a || b && c` is more clear than ``` if a then True else if b then if c then True else False else False ```
And some languages, `pureComputing || (ioOperation && pure2)` involves IO only when pureComputing is False.
So in Haskell, is it possible to get both benefits? ``` status <- ioOperation -- IO-ed anyway return $ pureComputing || (status && pure2) ``` ``` if pureComputing then return True else do status <- ioOperation if status then return pure2 else return False -- Looks ugly ``` _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.