[Haskell-cafe] flip1 through flip9, useful?

Stijn van Drongelen rhymoid at gmail.com
Tue Jan 14 23:42:16 UTC 2014


On Wed, Jan 15, 2014 at 12:30 AM, Christian Marie <christian at ponies.io>wrote:

> On Tue, Jan 14, 2014 at 04:57:14PM +1000, Tony Morris wrote:
> >    Why not generalise to any functor?
> >    let flip f a = fmap ($a) f
>
> I didn't think of that, I suppose.
>
> Now that I do, it seems to be a tradeoff between (arguably) less
> immediately
> obvious type signatures and something.
>
> I can't actually think of what that something is yet. Can you think of a
> real
> world use for a functor flip where normal flip wouldn't do?
>
>
I think it's mostly a skeleton to use for generalizing flip. Right now, you
have

    \f a -> fmap ($a) f :: Functor f => f (a -> b) -> a -> f b

so if you take (f ~ (->) c), you have

    \f a -> fmap ($a) f :: (c -> a -> b) -> (a -> c -> b)

For flips of higher arities, you would choose a different `f`, like (f ~
(->) d . (->) c):

    \f a -> fmap ($a) f :: (c -> d -> a -> b) -> (a -> c -> d -> b)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140115/1f12ce2c/attachment.html>


More information about the Haskell-Cafe mailing list