Should perhaps be noted that this exists in the lens package as "over both" and also for up to 9-tuples as "over each".


On Tue, Jan 8, 2013 at 3:21 AM, Daniel Díaz Casanueva <dhelta.diaz@gmail.com> wrote:
I don't know what is the best name for it, but I have found myself defining this function lot of times.


On Wed, Oct 10, 2012 at 7:15 AM, Merijn Verstraaten <merijn@inconsistent.nl> wrote:
I keep finding myself needing to apply functions to both elements in a tuple and now that I've started playing around with AFRP libraries I find myself applying arrows to both sides of tuples there too. As a result I would like to propose the following addition to Control.Arrow:

both :: Arrow a => a b c -> a (b, b) (c, c)
both = join (***)
-- or if importing join from Control.Monad is undesirable
both f = f *** f

Why not just write "f *** f" I hear you ask? Because when f is not a trivial expression then you need to either bind it to a new name and use "newName *** newName" (which I personally dislike, because I'm terrible at coming up with names) or write "join (***) f" which I don't find a particularly appealing notation either.

Kind regards,
Merijn Verstraaten

_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries