On Tue, May 28, 2013 at 10:54 AM, Dominique Devriese <dominique.devriese@cs.kuleuven.be> wrote:
Hi all,

I often find myself needing the following definitions:

  mapPair :: (a -> b) -> (c -> d) -> (a,c) -> (b,d)
  mapPair f g (x,y) = (f x, g y)

That's Control.Arrow.(***), e.g.:

    ghci> (+3) *** (*5) $ (20,30)
    (23,150)
 

  mapFst :: (a -> b) -> (a,c) -> (b,c)
  mapFst f = mapPair f id

  mapSnd :: (b -> c) -> (a,b) -> (a,c)
  mapSnd = mapPair id

That's Control.Arrow.{first, second}:

    ghci> first (+10) (1,1)
    (11,1)
    ghci> second (+10) (1,1)
    (1,11)

G
--
Gregory Collins <greg@gregorycollins.net>