module Data.Invertible.Tuple
( fst
, snd
, curry
, swap
, flatten1_2
, flatten1_3
, flatten1_4
, flatten2_1
, flatten2_2
, flatten3_1
, flatten4_1
) where
import Prelude hiding (fst, snd, curry, uncurry)
import qualified Data.Tuple as T
import Data.Invertible.Bijection
import Data.Invertible.TH
fst :: (a, ()) <-> a
fst = [biCase|(a, ()) <-> a|]
snd :: ((), a) <-> a
snd = [biCase|((), a) <-> a|]
curry :: ((a, b) -> c) <-> (a -> b -> c)
curry = T.curry :<->: T.uncurry
swap :: (a, b) <-> (b, a)
swap = [biCase|(a, b) <-> (b, a)|]
flatten2_1 :: ((a, b), c) <-> (a, b, c)
flatten2_1 = [biCase|((a, b), c) <-> (a, b, c)|]
flatten1_2 :: (a, (b, c)) <-> (a, b, c)
flatten1_2 = [biCase|(a, (b, c)) <-> (a, b, c)|]
flatten3_1 :: ((a, b, c), d) <-> (a, b, c, d)
flatten3_1 = [biCase|((a, b, c), d) <-> (a, b, c, d)|]
flatten1_3 :: (a, (b, c, d)) <-> (a, b, c, d)
flatten1_3 = [biCase|(a, (b, c, d)) <-> (a, b, c, d)|]
flatten2_2 :: ((a, b), (c, d)) <-> (a, b, c, d)
flatten2_2 = [biCase|((a, b), (c, d)) <-> (a, b, c, d)|]
flatten1_4 :: (a, (b, c, d, e)) <-> (a, b, c, d, e)
flatten1_4 = [biCase|(a, (b, c, d, e)) <-> (a, b, c, d, e)|]
flatten4_1 :: ((a, b, c, d), e) <-> (a, b, c, d, e)
flatten4_1 = [biCase|((a, b, c, d), e) <-> (a, b, c, d, e)|]