{-# LANGUAGE Safe #-}

{- |
    Module      :  SDP.Tuple
    Copyright   :  (c) Andrey Mulik 2019
    License     :  BSD-style
    Maintainer  :  work.a.mulik@gmail.com
    Portability :  portable
    
    "SDP.Tuple" provides tuple type synonyms.
-}
module SDP.Tuple
(
  -- * Tuple synonyms
  T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  
  -- * Related combinators
  fsts, snds, both
)
where

import Data.Function ( on )

default ()

--------------------------------------------------------------------------------

-- | Return all first elements in pairs.
fsts :: (Functor f) => f (a, b) -> f a
fsts :: f (a, b) -> f a
fsts =  ((a, b) -> a) -> f (a, b) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, b) -> a
forall a b. (a, b) -> a
fst

-- | Return all first elements in pairs.
snds :: (Functor f) => f (a, b) -> f b
snds :: f (a, b) -> f b
snds =  ((a, b) -> b) -> f (a, b) -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, b) -> b
forall a b. (a, b) -> b
snd

-- | Applies function to both elements of pair.
both :: (a -> b) -> (a, a) -> (b, b)
both :: (a -> b) -> (a, a) -> (b, b)
both =  (a -> a -> (b, b)) -> (a, a) -> (b, b)
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((a -> a -> (b, b)) -> (a, a) -> (b, b))
-> ((a -> b) -> a -> a -> (b, b)) -> (a -> b) -> (a, a) -> (b, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> b -> (b, b)) -> (a -> b) -> a -> a -> (b, b)
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on (,)

--------------------------------------------------------------------------------

-- | Tuple synonym
type T2  i = (i,i)
-- | Tuple synonym
type T3  i = (i,i,i)
-- | Tuple synonym
type T4  i = (i,i,i,i)
-- | Tuple synonym
type T5  i = (i,i,i,i,i)
-- | Tuple synonym
type T6  i = (i,i,i,i,i,i)
-- | Tuple synonym
type T7  i = (i,i,i,i,i,i,i)
-- | Tuple synonym
type T8  i = (i,i,i,i,i,i,i,i)
-- | Tuple synonym
type T9  i = (i,i,i,i,i,i,i,i,i)
-- | Tuple synonym
type T10 i = (i,i,i,i,i,i,i,i,i,i)
-- | Tuple synonym
type T11 i = (i,i,i,i,i,i,i,i,i,i,i)
-- | Tuple synonym
type T12 i = (i,i,i,i,i,i,i,i,i,i,i,i)
-- | Tuple synonym
type T13 i = (i,i,i,i,i,i,i,i,i,i,i,i,i)
-- | Tuple synonym
type T14 i = (i,i,i,i,i,i,i,i,i,i,i,i,i,i)
-- | Tuple synonym
type T15 i = (i,i,i,i,i,i,i,i,i,i,i,i,i,i,i)