That was my suspicion. So, you can't change horses (monads) in mid-stream.

A parallel question:

main = do ...    -- in the IO monad

I know I can have other *do*s in main,

  if foo
    then do
              .
              .
    else do
             .
             .

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*?

Thanks for your patience.

Michael

--- On Sun, 8/8/10, Henning Thielemann <[email protected]> wrote:

From: Henning Thielemann <[email protected]>
Subject: Re: [Haskell-cafe] What is <-
To: "michael rice" <[email protected]>
Date: Sunday, August 8, 2010, 11:01 AM


On Sun, 8 Aug 2010, michael rice wrote:

> How would I print each of these integers, one per line?
> 
> [1,2,3,4,5] >>= \x -> ?

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.

  mapM_ print [1..5]

or

  mapM_ print $ do
     x <- [1..]
     ...
     return (x+y+z)



      
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to