-- |
-- Module      : Test.Speculate.Utils.Tuple
-- Copyright   : (c) 2016-2019 Rudy Matela
-- License     : 3-Clause BSD  (see the file LICENSE)
-- Maintainer  : Rudy Matela <rudy@matela.com.br>
module Test.Speculate.Utils.Tuple
  ( module Data.Tuple
  , fst3, fst4
  , snd3, snd4
  , trd3, trd4
  ,       fth4
  , curry3, curry4
  , uncurry3, uncurry4, uncurry5, uncurry6, uncurry7
  , uncurry8, uncurry9, uncurry10, uncurry11, uncurry12
  , (***)
  , catPairs
  )
where

import Data.Tuple

fst3 :: (a,b,c) -> a
fst3 :: forall a b c. (a, b, c) -> a
fst3 (a
x,b
y,c
z) = a
x

snd3 :: (a,b,c) -> b
snd3 :: forall a b c. (a, b, c) -> b
snd3 (a
x,b
y,c
z) = b
y

trd3 :: (a,b,c) -> c
trd3 :: forall a b c. (a, b, c) -> c
trd3 (a
x,b
y,c
z) = c
z

fst4 :: (a,b,c,d) -> a
fst4 :: forall a b c d. (a, b, c, d) -> a
fst4 (a
x,b
y,c
z,d
w) = a
x

snd4 :: (a,b,c,d) -> b
snd4 :: forall a b c d. (a, b, c, d) -> b
snd4 (a
x,b
y,c
z,d
w) = b
y

trd4 :: (a,b,c,d) -> c
trd4 :: forall a b c d. (a, b, c, d) -> c
trd4 (a
x,b
y,c
z,d
w) = c
z

fth4 :: (a,b,c,d) -> d
fth4 :: forall a b c d. (a, b, c, d) -> d
fth4 (a
x,b
y,c
z,d
w) = d
w

curry3 :: ((a,b,c)->d) -> a -> b -> c -> d
curry3 :: forall a b c d. ((a, b, c) -> d) -> a -> b -> c -> d
curry3 (a, b, c) -> d
f a
x b
y c
z = (a, b, c) -> d
f (a
x,b
y,c
z)

curry4 :: ((a,b,c,d)->e) -> a -> b -> c -> d -> e
curry4 :: forall a b c d e. ((a, b, c, d) -> e) -> a -> b -> c -> d -> e
curry4 (a, b, c, d) -> e
f a
x b
y c
z d
w = (a, b, c, d) -> e
f (a
x,b
y,c
z,d
w)

uncurry3 :: (a->b->c->d) -> (a,b,c) -> d
uncurry3 :: forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
uncurry3 a -> b -> c -> d
f (a, b, c)
t = a -> b -> c -> d
f ((a, b, c) -> a
forall a b c. (a, b, c) -> a
fst3 (a, b, c)
t) ((a, b, c) -> b
forall a b c. (a, b, c) -> b
snd3 (a, b, c)
t) ((a, b, c) -> c
forall a b c. (a, b, c) -> c
trd3 (a, b, c)
t)

uncurry4 :: (a->b->c->d->e) -> (a,b,c,d) -> e
uncurry4 :: forall a b c d e. (a -> b -> c -> d -> e) -> (a, b, c, d) -> e
uncurry4 a -> b -> c -> d -> e
f (a, b, c, d)
q = a -> b -> c -> d -> e
f ((a, b, c, d) -> a
forall a b c d. (a, b, c, d) -> a
fst4 (a, b, c, d)
q) ((a, b, c, d) -> b
forall a b c d. (a, b, c, d) -> b
snd4 (a, b, c, d)
q) ((a, b, c, d) -> c
forall a b c d. (a, b, c, d) -> c
trd4 (a, b, c, d)
q) ((a, b, c, d) -> d
forall a b c d. (a, b, c, d) -> d
fth4 (a, b, c, d)
q)

uncurry5 :: (a->b->c->d->e->f) -> (a,b,c,d,e) -> f
uncurry5 :: forall a b c d e f.
(a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f
uncurry5 a -> b -> c -> d -> e -> f
f (a
x,b
y,c
z,d
w,e
v) = a -> b -> c -> d -> e -> f
f a
x b
y c
z d
w e
v

uncurry6 :: (a->b->c->d->e->f->g) -> (a,b,c,d,e,f) -> g
uncurry6 :: forall a b c d e f g.
(a -> b -> c -> d -> e -> f -> g) -> (a, b, c, d, e, f) -> g
uncurry6 a -> b -> c -> d -> e -> f -> g
f (a
x,b
y,c
z,d
w,e
v,f
u) = a -> b -> c -> d -> e -> f -> g
f a
x b
y c
z d
w e
v f
u

uncurry7 :: (a->b->c->d->e->f->g->h) -> (a,b,c,d,e,f,g) -> h
uncurry7 :: forall a b c d e f g h.
(a -> b -> c -> d -> e -> f -> g -> h)
-> (a, b, c, d, e, f, g) -> h
uncurry7 a -> b -> c -> d -> e -> f -> g -> h
f (a
x,b
y,c
z,d
w,e
v,f
u,g
r) = a -> b -> c -> d -> e -> f -> g -> h
f a
x b
y c
z d
w e
v f
u g
r

uncurry8 :: (a->b->c->d->e->f->g->h->i) -> (a,b,c,d,e,f,g,h) -> i
uncurry8 :: forall a b c d e f g h i.
(a -> b -> c -> d -> e -> f -> g -> h -> i)
-> (a, b, c, d, e, f, g, h) -> i
uncurry8 a -> b -> c -> d -> e -> f -> g -> h -> i
f (a
x,b
y,c
z,d
w,e
v,f
u,g
r,h
s) = a -> b -> c -> d -> e -> f -> g -> h -> i
f a
x b
y c
z d
w e
v f
u g
r h
s

uncurry9 :: (a->b->c->d->e->f->g->h->i->j) -> (a,b,c,d,e,f,g,h,i) -> j
uncurry9 :: forall a b c d e f g h i j.
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j)
-> (a, b, c, d, e, f, g, h, i) -> j
uncurry9 a -> b -> c -> d -> e -> f -> g -> h -> i -> j
f (a
x,b
y,c
z,d
w,e
v,f
u,g
r,h
s,i
t) = a -> b -> c -> d -> e -> f -> g -> h -> i -> j
f a
x b
y c
z d
w e
v f
u g
r h
s i
t

uncurry10 :: (a->b->c->d->e->f->g->h->i->j->k) -> (a,b,c,d,e,f,g,h,i,j) -> k
uncurry10 :: forall a b c d e f g h i j k.
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k)
-> (a, b, c, d, e, f, g, h, i, j) -> k
uncurry10 a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
f (a
x,b
y,c
z,d
w,e
v,f
u,g
r,h
s,i
t,j
o) = a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
f a
x b
y c
z d
w e
v f
u g
r h
s i
t j
o

uncurry11 :: (a->b->c->d->e->f->g->h->i->j->k->l)
          -> (a,b,c,d,e,f,g,h,i,j,k) -> l
uncurry11 :: forall a b c d e f g h i j k l.
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l)
-> (a, b, c, d, e, f, g, h, i, j, k) -> l
uncurry11 a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
f (a
x,b
y,c
z,d
w,e
v,f
u,g
r,h
s,i
t,j
o,k
p) = a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
f a
x b
y c
z d
w e
v f
u g
r h
s i
t j
o k
p

uncurry12 :: (a->b->c->d->e->f->g->h->i->j->k->l->m)
          -> (a,b,c,d,e,f,g,h,i,j,k,l) -> m
uncurry12 :: forall a b c d e f g h i j k l m.
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m)
-> (a, b, c, d, e, f, g, h, i, j, k, l) -> m
uncurry12 a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
f (a
x,b
y,c
z,d
w,e
v,f
u,g
r,h
s,i
t,j
o,k
p,l
q) = a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
f a
x b
y c
z d
w e
v f
u g
r h
s i
t j
o k
p l
q

(***) :: (a -> b) -> (c -> d) -> (a,c) -> (b,d)
a -> b
f *** :: forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
*** c -> d
g = \(a
x,c
y) -> (a -> b
f a
x, c -> d
g c
y)

catPairs :: [(a,a)] -> [a]
catPairs :: forall a. [(a, a)] -> [a]
catPairs [] = []
catPairs ((a
x,a
y):[(a, a)]
xys) = a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:a
ya -> [a] -> [a]
forall a. a -> [a] -> [a]
:[(a, a)] -> [a]
forall a. [(a, a)] -> [a]
catPairs [(a, a)]
xys