[Haskell-cafe] is the evaluation order deterministic when using applicative with IO

Brent Yorgey byorgey at seas.upenn.edu
Fri Mar 16 19:52:26 CET 2012


On Fri, Mar 16, 2012 at 12:30:13PM +0100, Twan van Laarhoven wrote:
> 
> If you want to avoid the side effects of boolTest2 when boolTest1
> returns true, you will need to implement a monadic or, something like
> 
>     orM ma mb = do
>         a <- ma
>         if a then return True else mb

Note also that it is *not possible* to have this short-circuiting
behavior using only Applicative.  The structure of an Applicative
computation is always fixed up front, and cannot depend on
intermediate values.

-Brent



More information about the Haskell-Cafe mailing list