<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">That was my suspicion. So, you can't change horses (monads) in mid-stream.<br><br>A parallel question:<br><br>main = do ... -- in the IO monad<br><br>I know I can have other *do*s in main,<br><br> if foo<br> then do<br> .<br> .<br> else do<br> .<br> .<br><br>but must all these other *do*s also be in the same IO monad? What determines what monad a *do* is "in"? The first line after the *do*?<br><br>Thanks for your patience.<br><br>Michael<br><br>--- On <b>Sun, 8/8/10, Henning Thielemann <i><lemming@henning-thielemann.de></i></b>
wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Henning Thielemann <lemming@henning-thielemann.de><br>Subject: Re: [Haskell-cafe] What is <-<br>To: "michael rice" <nowgate@yahoo.com><br>Date: Sunday, August 8, 2010, 11:01 AM<br><br><div class="plainMail"><br>On Sun, 8 Aug 2010, michael rice wrote:<br><br>> How would I print each of these integers, one per line?<br>> <br>> [1,2,3,4,5] >>= \x -> ?<br><br>You can't do this from inside the List monad, but you can easily do it from outside, since the result of a 'do' block in List monad is just a list.<br><br> mapM_ print [1..5]<br><br>or<br><br> mapM_ print $ do<br> x <- [1..]<br> ...<br> return (x+y+z)<br></div></blockquote></td></tr></table><br>