[Haskell-cafe] flip1 through flip9, useful?
Alexander Solla
alex.solla at gmail.com
Tue Jan 14 23:38:07 UTC 2014
On Mon, Jan 13, 2014 at 10:57 PM, Tony Morris <tonymorris at gmail.com> wrote:
> On 14/01/14 15:48, Christian Marie wrote:
>
> I have defined a bunch of functions like this:
>
> -- | Move the fourth argument to the first place
> rotate4 :: (a -> b -> c -> d -> e) -> (d -> a -> b -> c -> e)
>
> -- | Reverse four arguments
> flip4 :: (a -> b -> c -> d -> e) -> (d -> c -> b -> a -> e)
>
> I decided to upload this as a library to hackage, as I personally find it
> useful, especially for writing FFI bindings.
>
> It seems like I can't be the first to write a library like this though, am I
> missing something obvious? Is this useful or stupid? Does it exist already?
>
> Full definition here:
> https://github.com/christian-marie/flippers/blob/master/src/Control/Flippers.hs
>
>
>
> _______________________________________________
> Haskell-Cafe mailing listHaskell-Cafe at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe
>
> Why not generalise to any functor?
>
> let flip f a = fmap ($a) f
>
I don't see that operator as "flip-like", personally. It might behave as
flip in the case of the function functor , but that intuition does not
carry over to things like
fmap ($a) [f, g, h] = [f a, g a, h a]
I'd call it "funder", personally.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140114/6f4c3e93/attachment.html>
More information about the Haskell-Cafe
mailing list