[Haskell-cafe] Lazy Evaluation in Monads
Scott Lawrence
bytbox at gmail.com
Tue May 31 22:29:49 CEST 2011
On 05/31/2011 04:20 PM, Artyom Kazak wrote:
> Suppose iRecurse looks like this:
> iRecurse = do
> x <- launchMissiles
> r <- iRecurse
> return 1
>
> As x is never needed, launchMissiles will never execute. It obviously is
> not what is needed.
Prelude> let launchMissiles = putStrLn "UH OH" >> return 1
Prelude> let iRecurse = launchMissiles >> return 1
Prelude> iRecurse
UH OH
1
Prelude>
Looks like launchMissiles /does/ execute, even though x is (obviously)
never needed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110531/64b30f03/attachment.pgp>
More information about the Haskell-Cafe
mailing list