Simple addition to Control.Arrow

Merijn Verstraaten merijn at inconsistent.nl
Wed Oct 10 13:15:05 CEST 2012


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



More information about the Libraries mailing list