[Haskell-cafe] mapM is supralinear?
Tim Docker
tim at dockerz.net
Wed Sep 21 14:57:01 CEST 2011
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
More information about the Haskell-Cafe
mailing list