Add flipped fmap
Brent Yorgey
byorgey at seas.upenn.edu
Wed Apr 7 13:23:45 EDT 2010
On Wed, Apr 07, 2010 at 04:12:24PM +0200, Bas van Dijk wrote:
> On Wed, Apr 7, 2010 at 3:58 PM, Felipe Lessa <felipe.lessa at gmail.com> wrote:
> > Simmetry, as the ticket says.
>
> Indeed, I would like to emphasize that my main reason for adding a
> flipped fmap is symmetry. I find it hard to explain why <$$> shouldn't
> be in this list:
>
> (<$>) ∷ Functor f ⇒ (α → β) → (f α → f β)
> (<$$>) ∷ Functor f ⇒ f α → (α → β) → f β
>
> (<*>) ∷ Applicative f ⇒ f (α → β) → (f α → f β)
> (<**>) ∷ Applicative f ⇒ f α → f (α → β) → f β
>
> (>>=) ∷ Monad f ⇒ f α → (α → f β) → f β
> (=<<) ∷ Monad f ⇒ (α → f β) → (f α → f β)
Let me point out that (<**>) is NOT defined as flip (<*>)! In fact it is defined as
(<**>) = liftA2 (flip ($))
which is quite different, since it performs effects in the opposite
order from flip (<*>). So arguing for (<$$>) as something parallel to
(<**>) is a bit misleading. I don't know whether this lends support
to one argument or another; I'm personally fairly neutral on the
proposal, but I thought this was important to point out.
-Brent
More information about the Libraries
mailing list