[Haskell-cafe] How to make boolean logic with IO Monad more expressive?
Magicloud Magiclouds
magicloud.magiclouds at gmail.com
Mon May 27 05:07:37 UTC 2019
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
```
More information about the Haskell-Cafe
mailing list