---------------------------------------------------------------------
--
-- Module      :  Uniform.Pointless
--              collecting some of the operations used in
--              the book by
--              Bird \& deMoore \"The Algebra of Programming\"
----------------------------------------------------------------------

module Uniform.Pointless (module Uniform.Pointless) where

pair :: (t -> b) -> (t, t) -> (b, b)
pair :: (t -> b) -> (t, t) -> (b, b)
pair t -> b
f (t
a, t
b) = (t -> b
f t
a, t -> b
f t
b)

cross :: (t1 -> a, t2 -> b) -> (t1, t2) -> (a, b)
cross :: (t1 -> a, t2 -> b) -> (t1, t2) -> (a, b)
cross (t1 -> a
f, t2 -> b
g) (t1
a, t2
b) = (t1 -> a
f t1
a, t2 -> b
g t2
b)

swapPair :: (b, a) -> (a, b)
swapPair :: (b, a) -> (a, b)
swapPair (b
a, a
b) = (a
b, b
a)

first :: (t -> a) -> (t, b) -> (a, b)
first :: (t -> a) -> (t, b) -> (a, b)
first t -> a
f (t
a, b
b) = (t -> a
f t
a, b
b)

second :: (t -> b) -> (a, t) -> (a, b)
second :: (t -> b) -> (a, t) -> (a, b)
second t -> b
f (a
a, t
b) = (a
a, t -> b
f t
b)

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

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

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

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

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

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

thd4 :: (a, b, c, d) -> c
thd4 :: (a, b, c, d) -> c
thd4 = (a, b, c, d) -> c
forall a b c d. (a, b, c, d) -> c
trd4

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

fst5 :: (a, b, c, d, e) -> a
fst5 :: (a, b, c, d, e) -> a
fst5 (a
x, b
y, c
z, d
w, e
u) = a
x

snd5 :: (a, b, c, d, e) -> b
snd5 :: (a, b, c, d, e) -> b
snd5 (a
x, b
y, c
z, d
w, e
u) = b
y

thd5 :: (a, b, c, d, e) -> c
thd5 :: (a, b, c, d, e) -> c
thd5 (a
x, b
y, c
z, d
w, e
u) = c
z

trd5 :: (a, b, c, d, e) -> c
trd5 :: (a, b, c, d, e) -> c
trd5 = (a, b, c, d, e) -> c
forall a b c d e. (a, b, c, d, e) -> c
thd5

fth5 :: (a, b, c, d, e) -> d
fth5 :: (a, b, c, d, e) -> d
fth5 (a
x, b
y, c
z, d
w, e
u) = d
w

ffh5 :: (a, b, c, d, e) -> e
ffh5 :: (a, b, c, d, e) -> e
ffh5 (a
x, b
y, c
z, d
w, e
u) = e
u

first3 :: (a1 -> b) -> (a1, a2, a3) -> (b, a2, a3)
first3 :: (a1 -> b) -> (a1, a2, a3) -> (b, a2, a3)
first3 a1 -> b
f (a1
a1, a2
a2, a3
a3) = (a1 -> b
f a1
a1, a2
a2, a3
a3)

second3 :: (a2 -> b) -> (a1, a2, a3) -> (a1, b, a3)
second3 :: (a2 -> b) -> (a1, a2, a3) -> (a1, b, a3)
second3 a2 -> b
f (a1
a1, a2
a2, a3
a3) = (a1
a1, a2 -> b
f a2
a2, a3
a3)

third3 :: (a3 -> b) -> (a1, a2, a3) -> (a1, a2, b)
third3 :: (a3 -> b) -> (a1, a2, a3) -> (a1, a2, b)
third3 a3 -> b
f (a1
a1, a2
a2, a3
a3) = (a1
a1, a2
a2, a3 -> b
f a3
a3)

first4 :: (a1 -> b) -> (a1, a2, a3, a4) -> (b, a2, a3, a4)
first4 :: (a1 -> b) -> (a1, a2, a3, a4) -> (b, a2, a3, a4)
first4 a1 -> b
f (a1
a1, a2
a2, a3
a3, a4
a4) = (a1 -> b
f a1
a1, a2
a2, a3
a3, a4
a4)

second4 :: (a2 -> b) -> (a1, a2, a3, a4) -> (a1, b, a3, a4)
second4 :: (a2 -> b) -> (a1, a2, a3, a4) -> (a1, b, a3, a4)
second4 a2 -> b
f (a1
a1, a2
a2, a3
a3, a4
a4) = (a1
a1, a2 -> b
f a2
a2, a3
a3, a4
a4)

third4 :: (a3 -> b) -> (a1, a2, a3, a4) -> (a1, a2, b, a4)
third4 :: (a3 -> b) -> (a1, a2, a3, a4) -> (a1, a2, b, a4)
third4 a3 -> b
f (a1
a1, a2
a2, a3
a3, a4
a4) = (a1
a1, a2
a2, a3 -> b
f a3
a3, a4
a4)

fourth4 :: (a4 -> b) -> (a1, a2, a3, a4) -> (a1, a2, a3, b)
fourth4 :: (a4 -> b) -> (a1, a2, a3, a4) -> (a1, a2, a3, b)
fourth4 a4 -> b
f (a1
a1, a2
a2, a3
a3, a4
a4) = (a1
a1, a2
a2, a3
a3, a4 -> b
f a4
a4)