[Haskell-cafe] Is 'flip' really necessary?

Antoine Latter aslatter at gmail.com
Sun Jul 25 17:23:40 EDT 2010

On Sun, Jul 25, 2010 at 4:13 PM, aditya siram <aditya.siram at gmail.com> wrote:
> Eta-reducing is nice, and sometimes it makes code more readable. But 'flip'
> is one of those functions that always seems to hinder rather than help
> readability, conversely factoring out flip always makes code easier to
> comprehend. I don't see a need for its existence - maybe I'm missing
> something and more experienced Haskellers can comment.

I'm a fan of (flip map), (flip mapM) and the like. These are usually
renamed 'for' and 'forM' (and then 'forM_', of course).

It makes for nice in-line function literals:

> flip map xs $ \elem ->
>        do something long and complex
>        with xs


More information about the Haskell-Cafe mailing list