
5 Jun
2012
5 Jun
'12
7:40 p.m.
On Tue, 5 Jun 2012, Andreas Abel wrote:
The reason to have a mapM_ additionally to mapM is that in some cases, e.g. as last statement of a do block of type m (), mapM does not type check.
The functions mapM and mapM_ are really distinct. That's why they are generalized in different modules: mapM_ is generalized in Foldable mapM is generalized in Traversable Using mapM instead of mapM_ can lead to a memory leak and I think the confusion between mapM and mapM_ was the initial reason to add the unused-binding warning to GHC. And it actually helped me spotting a lot of calls to mapM that have to be calls to mapM_.