[Haskell-cafe] Re: Explaining monads

Brian Brunswick brian at ithil.org
Mon Aug 13 18:35:29 EDT 2007


On 13/08/07, David Roundy <droundy at darcs.net> wrote:
>
> Try executing:
>
>   do { x <- return 2; undefined; return (x*x); }
>
> in any monad you like, and you'll find that regardless of the *data*
> dependencies (the return value of this monadic action is unambiguous), the
> undefined is evaluated *before* the value 4 is returned.
> --
>
>
Prelude> :m + Control.Monad.Identity
Prelude Control.Monad.Identity> runIdentity $ do { x <- return 2; undefined;
return (x*x); }
Loading package mtl-1.0 ... linking ... done.
4

-- 
Brian_Brunswick____brian at ithil.org____Wit____Disclaimer____!Shortsig_rules!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070813/74d8866c/attachment-0001.htm


More information about the Haskell-Cafe mailing list