You're looking for mapM_<br>
mapM_ :: (Monad m) => (a -> m b) -> [a] -> m ()<br>
(see also sequence_ :: (Monad m) => [m a] -> m () )<br>
<br>
I don't think that it is possible to have a 1-tuples, just 2 and up. () is a unit rather than a 0-tuple, apparently:<br>
<a href="http://www.haskell.org/onlinereport/basic.html#sect6.1.4" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.haskell.org/onlinereport/basic.html#sect6.1.4</a><br><br><div><span class="gmail_quote">On 10/03/2008, <b class="gmail_sendername">Paulo J. Matos</b> <<a href="mailto:pocm@soton.ac.uk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">pocm@soton.ac.uk</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello all,<br> <br> I find it funny that IO () is different from IO [()].<br> For example, if I define a function to output some lines with mapT, I would do:<br> outputLines :: Int -> IO ()<br> outputLines i = mapM (putStrLn . show) (take i $ iterate ((+) 1) 1)<br>
<br> However, this is in fact<br> outputLines :: Int -> IO [()]<br> <br> I would like to know if in fact there's any difference in practice<br> between (), [()], i.e. if in practice the difference matters.<br> My first guess is that this is just a consequence of the Haskell type<br>
system and so that everything fits this really needs to be like this.<br> Because<br> mapM :: (Monad m) => (a -> m b) -> [a] -> m [b]<br> <br> So I guess that it makes sense that you get IO [()] instead of IO (),<br>
and adding an exception just to say that [()] == () isn't good.<br> By the way, as a consequence can you possibly get IO (()) or IO ([()])<br> and are these all different from each other?<br> <br> Cheers,<br> <br> --<br>
Paulo Jorge Matos - pocm at <a href="http://soton.ac.uk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">soton.ac.uk</a><br> <a href="http://www.personal.soton.ac.uk/pocm" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.personal.soton.ac.uk/pocm</a><br>
PhD Student @ ECS<br> University of Southampton, UK<br>
Sponsor ECS runners - Action against Hunger:<br> <a href="http://www.justgiving.com/ecsrunslikethewind" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.justgiving.com/ecsrunslikethewind</a><br>
_______________________________________________<br> Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Haskell-Cafe@haskell.org</a><br> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>