{- |
Module      : Antelude.Tuple.Pair
Description : Contains some functions for a two-member Tuple (a Pair).
Maintainer  : dneavesdev@pm.me
-}
module Antelude.Tuple.Pair
    ( Pair
    , curry
    , first
    , mapFirst
    , mapSecond
    , pack
    , second
    , swap
    , uncurry
    ) where

import safe           Antelude.Internal.TypesClasses ( Pair )

import safe           Data.Tuple                     ( curry, uncurry )


-- | Get the first item of a 'Pair' Tuple
first :: Pair a b -> a
first :: forall a b. Pair a b -> a
first (a
a, b
_) = a
a


-- | Get the second item of a 'Pair' Tuple
second :: Pair a b -> b
second :: forall a b. Pair a b -> b
second (a
_, b
b) = b
b


-- | Apply a function to the first item of a 'Pair' Tuple
mapFirst :: (a -> z) -> Pair a b -> Pair z b
mapFirst :: forall a z b. (a -> z) -> Pair a b -> Pair z b
mapFirst a -> z
fn (a
a, b
b) = (a -> z
fn a
a, b
b)


-- | Apply a function to the second item of a 'Pair' Tuple
mapSecond :: (b -> z) -> Pair a b -> Pair a z
mapSecond :: forall b z a. (b -> z) -> Pair a b -> Pair a z
mapSecond b -> z
fn (a
a, b
b) = (a
a, b -> z
fn b
b)


-- | Swap the items in a 'Pair' Tuple
swap :: Pair a b -> Pair b a
swap :: forall a b. Pair a b -> Pair b a
swap (a
a, b
b) = (b
b, a
a)


-- | Pack both arguments into a 'Pair' Tuple
pack :: a -> b -> Pair a b
pack :: forall a b. a -> b -> Pair a b
pack a
a b
b = (a
a, b
b)