[Haskell-beginners] forM vs mapM
Gaius Hammond
Gaius at Gaius.org.UK
Thu Aug 19 06:16:06 EDT 2010
Thanks, I suspected that might be the case but it seemed too simple :-)
Cheers,
G
------------------
-----Original Message-----
From: Thomas Davie <tom.davie at gmail.com>
Date: Thu, 19 Aug 2010 11:08:34
To: <Gaius at Gaius.org.UK>
Cc: Haskell Beginners List<beginners at haskell.org>
Subject: Re: [Haskell-beginners] forM vs mapM
On 19 Aug 2010, at 11:02, Gaius Hammond wrote:
> Hi all,
>
>
> Can anyone give me an example of a situation where you would use forM but *not* mapM or vice versa? As far as I can see one is simply a flip of the other. Does forM make any guarantees about order of execution?
Nope, no extra guarentees, just reverses the argument order.
forM can look quite nice if you have a large function that you want to map...
forM [someList]
lots of
large function
here
...
while mapM can look good if you have a small function...
mapM simpleFunction [someList]
They're also useful both ways round partially applied.
Bob
More information about the Beginners
mailing list