Add flipped fmap
wren ng thornton
wren at community.haskell.org
Thu Apr 8 20:27:52 EDT 2010
Edward Kmett wrote:
> I think in many ways the strict left to right effect evaluation order is
> what makes Applicative code readable.
I was going to mention that as the potential downside. However, I'd
interpret my version in the same vein as ($!). That is: evaluate the
argument, evaluate the function, invoke function on argument. The ($!)
combinator violates the standard call-by-need ordering, just as
flip(<**>) violates the standard left-to-right ordering, but people
don't generally find ($!) unintuitive...
Of course, both are CPS transformations for the sake of controlling
order of evaluation. The ($!) and flip(<**>) versions allow this
transformation to be implicit by retaining the usual direct-style
ordering of application; whereas flip($!) and (<**>) make the CPS
ordering of application explicit. Reasoning in CPS doesn't bother me,
but I think it's more elegant to be locally consistent about which style
is being used.
More information about the Libraries