New patches: [Add &&&, ***, onFst and onSnd to Data.Tuple Josef Svenningsson **20070921165445 Some people import Control.Arrow just to get access to the functions &&& and *** specialized to the function arrow. This patch add the specialized version of these two functions to Data.Tuple which is more logical thing to import if you wish to have functions operating on tuples. We also add onFst and onSnd which are specialized versions of first and second. ] { hunk ./Data/Tuple.hs 21 + , onFst -- :: (a -> a') -> (a,b) -> (a',b) + , onSnd -- :: (b -> b') -> (a,b) -> (a,b') + , (&&&) -- :: (a -> b) -> (a -> c) -> a -> (b,c) + , (***) -- :: (a -> a') -> (b -> b') -> (a,b) -> (a',b') hunk ./Data/Tuple.hs 282 +-- | Applies a function to the first component of a pair. +onFst :: (a -> a') -> (a,b) -> (a',b) +onFst f (a,b) = (f a,b) + +-- | Applies a function to the second component of a pair. +onSnd :: (b -> b') -> (a,b) -> (a,b') +onSnd g (a,b) = (a,g b) + +infixr 3 &&& + +-- | Construct a tuple using two functions which applied to the same +-- argument returns the respective tuple components. +(&&&) :: (a -> b) -> (a -> c) -> a -> (b,c) +f &&& g = \a -> (f a, g a) + +infixr 3 *** + +-- | Apply two functions pointwise to a pair. +(***) :: (a -> a') -> (b -> b') -> (a,b) -> (a',b') +f *** g = \ (a,b) -> (f a, g b) + } Context: [put extra-tmp-files field in the right place Simon Marlow **20070914140812] [Add more entries to boring file Ian Lynagh **20070913210500] [Add a boring file Ian Lynagh **20070913204641] [TAG 2007-09-13 Ian Lynagh **20070913215720] Patch bundle hash: 34748a2a88c97958617c179665ac36ff0fc115ae