{- Copyright (c) 2011 Robert Henderson
This source file is distributed under the terms of a BSD3-style
license, which can be found in the file LICENSE at the root of
this package. -}

-- | Extends "Data.Tuple"
--
module Data.Tuple.Rosso1
    (module Data.Tuple

    ,mapFst
    ,mapSnd
    ,pairApply

    ) where

------------------------------------------------------
import Data.Tuple


-- | Applies a function to the first component of a pair.
--
mapFst :: (a -> c) -> (a, b) -> (c, b)
mapFst f (a, b) = (f a, b)


-- | Applies a function to the second component of a pair.
--
mapSnd :: (b -> c) -> (a, b) -> (a, c)
mapSnd f (a, b) = (a, f b)


-- | Applies a pair of functions to a pair of values.
--
pairApply :: (a -> c) -> (b -> d) -> (a, b) -> (c, d)
pairApply f g (a, b) = (f a, g b)



-----------------------------------------------------------
{- UNIT TESTS

*Util.Tuple1e> mapFst (+ 10) (3, 5)
(13,5)
*Util.Tuple1e> mapSnd (+ 10) (3, 5)
(3,15)

*Rosso.Tuple1> pairApply (+ 5) tail (2, "abc")
(7,"bc")

-}