On 09/09/2011, at 8:19 PM, John Lato wrote:

Agreed.  Whenever I'd like to use mapM (or any other function for
which a *M_ is available), I've found the following rules helpful:

1. If I can guarantee the list is short (~ n<=20), go ahead and use mapM
2.  Otherwise use mapM_, foldM_, or foldM if a real reduction is
possible (i.e. not "foldM snocM []").

Step 2 sometimes requires changing my design, but it's always been for
the better.  `mapM_` tends to require more pipeline composition, so
it's leveraging the language's strengths.

This thread is really interesting - it relates directly to problems I am currently having with mapM over large lists (see the thread "stack overflow pain").

Can you explain what you mean by "mapM_ tends to require more pipeline composition"?
In what way is it leveraging the language strengths?

Thanks,

Tim

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

Reply via email to