[Haskell-cafe] for = flip map

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Wed Mar 28 21:58:20 CEST 2012


Good: we have  mapM, and we have forM ( = flip mapM )  .

Sure this is just a convenience, and indeed
"forM xs $ \ x -> do ..." is quite handy,
especially if "xs" is really small, 
and "..." is some larger expression.

Bad: we have  map,  but we are missing:  for ( = flip map ) .

The function is very convenient, for the same reasons as above.
I can't remember how often I typed "for = flip map" in a source file.
I never put this definition in a module either, 
since the import statement would be longer than the definition.

So, I'm all for "for" .  

In Data.List? In the Prelude? (Should put it right next to "map".) 

- J.W.




More information about the Haskell-Cafe mailing list