[Haskell-cafe] Is 'flip' really necessary?
Ivan Miljenovic
ivan.miljenovic at gmail.com
Mon Jul 26 02:39:32 EDT 2010
On 26 July 2010 16:33, David Virebayre <dav.vire+haskell at gmail.com> wrote:
> On Sun, Jul 25, 2010 at 11:53 PM, Edward Z. Yang <ezyang at mit.edu> wrote:
>
>> An interesting alternate spin on flip is infix notation combined with partial
>> application, such as:
>>
>> (`foobar` 3)
>>
>> which is equivalent to
>>
>> \x -> foobar x 3
>>
>> I frequently use this, although the jury's out on whether or not it's more readable.
>
> I had HLint suggest me this :
>
> before :
>
> listeEtagTot = concatMap (flip listeEtagArm cfgTypesTringle) listeArmOrd
>
> after :
>
> listeEtagTot = concatMap (`listeEtagArm` cfgTypesTringle) listeArmOrd
However, if you had something like this, I think the flip version is nicer:
With flip:
foo = map (f . flip g x)
Without flip:
foo = map (f . (`g` x))
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com
More information about the Haskell-Cafe
mailing list