On Friday 09 September 2011, 00:41:11, Roman Cheplyaka wrote: > * Ertugrul Soeylemez <e...@ertes.de> [2011-09-07 16:20:03+0200] > > > In general it's a bad idea to use mapM over IO. > > Could you explain why?
Take it with a grain of salt, there's nothing necessarily wrong with using mapM over IO on short lists. The problem is that IO's semantics imply that nothing can be made available before the entire list has been consumed and a large thunk is built on the way. Thus for longish lists there's a serious risk of stack overflows (or even heap exhaustion if you mapM the right [wrong] functions). The same applies to replicateM, and to other monads with a (>>=) which isn't lazy enough. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe