[Haskell-cafe] [Haskell] ANN: monad-bool 0.1

Henning Thielemann lemming at henning-thielemann.de
Wed Jan 23 01:12:48 CET 2013


On Tue, 22 Jan 2013, John Wiegley wrote:

> Use 'onlyIf' with AndM and AndMT to guard later statements, which are only
> evaluated if every preceding 'onlyIf' evaluates to True.  For example:
>
>    foo :: AndM Int
>    foo = do onlyIf (True == True)
>             return 100
>             onlyIf (True == True)
>             return 150
>             onlyIf (True == False)
>             return 200
>
> When run with `evalAndM foo (-1)` (where (-1) provides a default value), 'foo'
> returns 150.

Does the And monad fulfill the monad laws? In a proper monad an interim 
(return x) (without a '<-') is a no-op.



More information about the Haskell-Cafe mailing list