module Data.Tuple.HT where
mapPair :: (a -> c, b -> d) -> (a,b) -> (c,d)
mapPair ~(f,g) ~(x,y) = (f x, g y)
mapFst :: (a -> c) -> (a,b) -> (c,b)
mapFst f ~(a,b) = (f a, b)
mapSnd :: (b -> c) -> (a,b) -> (a,c)
mapSnd f ~(a,b) = (a, f b)
swap :: (a,b) -> (b,a)
swap ~(x,y) = (y,x)
forcePair :: (a,b) -> (a,b)
forcePair ~(x,y) = (x,y)
fst3 :: (a,b,c) -> a
fst3 ~(x,_,_) = x
snd3 :: (a,b,c) -> b
snd3 ~(_,x,_) = x
thd3 :: (a,b,c) -> c
thd3 ~(_,_,x) = x
mapTriple :: (a -> d, b -> e, c -> f) -> (a,b,c) -> (d,e,f)
mapTriple ~(f,g,h) ~(x,y,z) = (f x, g y, h z)
mapFst3 :: (a -> d) -> (a,b,c) -> (d,b,c)
mapFst3 f ~(a,b,c) = (f a, b, c)
mapSnd3 :: (b -> d) -> (a,b,c) -> (a,d,c)
mapSnd3 f ~(a,b,c) = (a, f b, c)
mapThd3 :: (c -> d) -> (a,b,c) -> (a,b,d)
mapThd3 f ~(a,b,c) = (a, b, f c)
curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d
curry3 f a b c = f (a,b,c)
uncurry3 :: (a -> b -> c -> d) -> ((a, b, c) -> d)
uncurry3 f ~(a,b,c) = f a b c