
15 Jun
2012
15 Jun
'12
7:28 a.m.
On Fri, Jun 15, 2012 at 11:25:56AM +0100, Herbert Valerio Riedel wrote:
Ivan Lazar Miljenovic
writes: mapPair :: (a -> c, b -> d) -> (a, b) -> (c, d) mapFst :: (a -> c) -> (a, b) -> (c, b) mapSnd :: (b -> c) -> (a, b) -> (a, c)
I believe these are covered by Control.Arrow...
I'm not sure those are really equivalent, as the ones from "Data.Tuple.HT" use lazy pattern matching, e.g.:
mapPair ~(f,g) ~(x,y) = (f x, g y)
mapFst f ~(a,b) = (f a, b)
mapSnd f ~(a,b) = (a, f b)
From Control.Arrow:
instance Arrow (->) where arr f = f first f = f *** id second f = id *** f (***) f g ~(x,y) = (f x, g y)