{-# language FlexibleContexts #-}
{-# language FlexibleInstances #-}
{-# language MultiParamTypeClasses #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- |
-- Module       : Data.Tuple.Strict.Lens.Iso
-- Copyright    : (c) 2020 Emily Pillmore
-- License      : BSD-style
--
-- Maintainer   : Emily Pillmore <emilypi@cohomolo.gy>
-- Stability    : Experimental
-- Portability  : portable
--
-- This module exports 'Control.Lens.Iso.Swapped' and
-- 'Control.Lens.Iso.Strict' instances for 'T1' through 'T9'
--
module Data.Tuple.Strict.Lens.Iso
( Swapped(..)
, Strict(..)
) where

import Control.Lens.Iso (Swapped(..), Strict(..), iso)

import Data.Functor.Identity
import Data.Tuple.Strict


-- ---------------------------------------------------------------- --
-- Swapped instances

instance Swapped T2 where
  swapped :: p (T2 b a) (f (T2 d c)) -> p (T2 a b) (f (T2 c d))
swapped = (T2 a b -> T2 b a)
-> (T2 d c -> T2 c d) -> Iso (T2 a b) (T2 c d) (T2 b a) (T2 d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T2 a b -> T2 b a
forall a b. T2 a b -> T2 b a
sswap T2 d c -> T2 c d
forall a b. T2 a b -> T2 b a
sswap
  {-# inline swapped #-}

instance Swapped (T3 x) where
  swapped :: p (T3 x b a) (f (T3 x d c)) -> p (T3 x a b) (f (T3 x c d))
swapped = (T3 x a b -> T3 x b a)
-> (T3 x d c -> T3 x c d)
-> Iso (T3 x a b) (T3 x c d) (T3 x b a) (T3 x d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T3 x a b -> T3 x b a
forall a c b. T3 a c b -> T3 a b c
f T3 x d c -> T3 x c d
forall a c b. T3 a c b -> T3 a b c
f
    where
      f :: T3 a c b -> T3 a b c
f (T3 a
x c
a b
b) = a -> b -> c -> T3 a b c
forall a b c. a -> b -> c -> T3 a b c
T3 a
x b
b c
a
  {-# inline swapped #-}

instance Swapped (T4 x y) where
  swapped :: p (T4 x y b a) (f (T4 x y d c)) -> p (T4 x y a b) (f (T4 x y c d))
swapped = (T4 x y a b -> T4 x y b a)
-> (T4 x y d c -> T4 x y c d)
-> Iso (T4 x y a b) (T4 x y c d) (T4 x y b a) (T4 x y d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T4 x y a b -> T4 x y b a
forall a b d c. T4 a b d c -> T4 a b c d
f T4 x y d c -> T4 x y c d
forall a b d c. T4 a b d c -> T4 a b c d
f
    where
      f :: T4 a b d c -> T4 a b c d
f (T4 a
x b
y d
a c
b) = a -> b -> c -> d -> T4 a b c d
forall a b c d. a -> b -> c -> d -> T4 a b c d
T4 a
x b
y c
b d
a
  {-# inline swapped #-}

instance Swapped (T5 x y z) where
  swapped :: p (T5 x y z b a) (f (T5 x y z d c))
-> p (T5 x y z a b) (f (T5 x y z c d))
swapped = (T5 x y z a b -> T5 x y z b a)
-> (T5 x y z d c -> T5 x y z c d)
-> Iso (T5 x y z a b) (T5 x y z c d) (T5 x y z b a) (T5 x y z d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T5 x y z a b -> T5 x y z b a
forall a b c e d. T5 a b c e d -> T5 a b c d e
f T5 x y z d c -> T5 x y z c d
forall a b c e d. T5 a b c e d -> T5 a b c d e
f
    where
      f :: T5 a b c e d -> T5 a b c d e
f (T5 a
x b
y c
z e
a d
b) = a -> b -> c -> d -> e -> T5 a b c d e
forall a b c d e. a -> b -> c -> d -> e -> T5 a b c d e
T5 a
x b
y c
z d
b e
a
  {-# inline swapped #-}

instance Swapped (T6 x y z w) where
  swapped :: p (T6 x y z w b a) (f (T6 x y z w d c))
-> p (T6 x y z w a b) (f (T6 x y z w c d))
swapped = (T6 x y z w a b -> T6 x y z w b a)
-> (T6 x y z w d c -> T6 x y z w c d)
-> Iso
     (T6 x y z w a b) (T6 x y z w c d) (T6 x y z w b a) (T6 x y z w d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T6 x y z w a b -> T6 x y z w b a
forall a b c d f e. T6 a b c d f e -> T6 a b c d e f
f T6 x y z w d c -> T6 x y z w c d
forall a b c d f e. T6 a b c d f e -> T6 a b c d e f
f
    where
      f :: T6 a b c d f e -> T6 a b c d e f
f (T6 a
x b
y c
z d
w f
a e
b) = a -> b -> c -> d -> e -> f -> T6 a b c d e f
forall a b c d e f. a -> b -> c -> d -> e -> f -> T6 a b c d e f
T6 a
x b
y c
z d
w e
b f
a
  {-# inline swapped #-}

instance Swapped (T7 x y z w v) where
  swapped :: p (T7 x y z w v b a) (f (T7 x y z w v d c))
-> p (T7 x y z w v a b) (f (T7 x y z w v c d))
swapped = (T7 x y z w v a b -> T7 x y z w v b a)
-> (T7 x y z w v d c -> T7 x y z w v c d)
-> Iso
     (T7 x y z w v a b)
     (T7 x y z w v c d)
     (T7 x y z w v b a)
     (T7 x y z w v d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T7 x y z w v a b -> T7 x y z w v b a
forall a b c d e g f. T7 a b c d e g f -> T7 a b c d e f g
f T7 x y z w v d c -> T7 x y z w v c d
forall a b c d e g f. T7 a b c d e g f -> T7 a b c d e f g
f
    where
      f :: T7 a b c d e g f -> T7 a b c d e f g
f (T7 a
x b
y c
z d
w e
v g
a f
b) = a -> b -> c -> d -> e -> f -> g -> T7 a b c d e f g
forall a b c d e f g.
a -> b -> c -> d -> e -> f -> g -> T7 a b c d e f g
T7 a
x b
y c
z d
w e
v f
b g
a
  {-# inline swapped #-}

instance Swapped (T8 x y z w v u) where
  swapped :: p (T8 x y z w v u b a) (f (T8 x y z w v u d c))
-> p (T8 x y z w v u a b) (f (T8 x y z w v u c d))
swapped = (T8 x y z w v u a b -> T8 x y z w v u b a)
-> (T8 x y z w v u d c -> T8 x y z w v u c d)
-> Iso
     (T8 x y z w v u a b)
     (T8 x y z w v u c d)
     (T8 x y z w v u b a)
     (T8 x y z w v u d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T8 x y z w v u a b -> T8 x y z w v u b a
forall a b c d e f h g. T8 a b c d e f h g -> T8 a b c d e f g h
f T8 x y z w v u d c -> T8 x y z w v u c d
forall a b c d e f h g. T8 a b c d e f h g -> T8 a b c d e f g h
f
    where
      f :: T8 a b c d e f h g -> T8 a b c d e f g h
f (T8 a
x b
y c
z d
w e
v f
a h
b g
c) = a -> b -> c -> d -> e -> f -> g -> h -> T8 a b c d e f g h
forall a b c d e f g h.
a -> b -> c -> d -> e -> f -> g -> h -> T8 a b c d e f g h
T8 a
x b
y c
z d
w e
v f
a g
c h
b
  {-# inline swapped #-}

instance Swapped (T9 a b c d e f g) where
  swapped :: p (T9 a b c d e f g b a) (f (T9 a b c d e f g d c))
-> p (T9 a b c d e f g a b) (f (T9 a b c d e f g c d))
swapped = (T9 a b c d e f g a b -> T9 a b c d e f g b a)
-> (T9 a b c d e f g d c -> T9 a b c d e f g c d)
-> Iso
     (T9 a b c d e f g a b)
     (T9 a b c d e f g c d)
     (T9 a b c d e f g b a)
     (T9 a b c d e f g d c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso T9 a b c d e f g a b -> T9 a b c d e f g b a
forall a b c d e f g i h.
T9 a b c d e f g i h -> T9 a b c d e f g h i
k T9 a b c d e f g d c -> T9 a b c d e f g c d
forall a b c d e f g i h.
T9 a b c d e f g i h -> T9 a b c d e f g h i
k
    where
      k :: T9 a b c d e f g i h -> T9 a b c d e f g h i
k (T9 a
a b
b c
c d
d e
e f
f g
g i
h h
i) = a -> b -> c -> d -> e -> f -> g -> h -> i -> T9 a b c d e f g h i
forall a b c d e f g h i.
a -> b -> c -> d -> e -> f -> g -> h -> i -> T9 a b c d e f g h i
T9 a
a b
b c
c d
d e
e f
f g
g h
i i
h
  {-# inline swapped #-}

-- ---------------------------------------------------------------- --
-- Strict instances

instance Strict (Identity a) (T1 a) where
  strict :: p (T1 a) (f (T1 a)) -> p (Identity a) (f (Identity a))
strict = (Identity a -> T1 a)
-> (T1 a -> Identity a) -> Iso' (Identity a) (T1 a)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(Identity a
a) -> a -> T1 a
forall a. a -> T1 a
T1 a
a) (\(T1 a
a) -> a -> Identity a
forall a. a -> Identity a
Identity a
a)
  {-# inline strict #-}

instance Strict (a,b) (T2 a b) where
  strict :: p (T2 a b) (f (T2 a b)) -> p (a, b) (f (a, b))
strict = ((a, b) -> T2 a b) -> (T2 a b -> (a, b)) -> Iso' (a, b) (T2 a b)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(a
a,b
b) -> a -> b -> T2 a b
forall a b. a -> b -> T2 a b
T2 a
a b
b) (\(T2 a
a b
b) -> (a
a,b
b))
  {-# inline strict #-}

instance Strict (a,b,c) (T3 a b c) where
  strict :: p (T3 a b c) (f (T3 a b c)) -> p (a, b, c) (f (a, b, c))
strict = ((a, b, c) -> T3 a b c)
-> (T3 a b c -> (a, b, c)) -> Iso' (a, b, c) (T3 a b c)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(a
a,b
b,c
c) -> a -> b -> c -> T3 a b c
forall a b c. a -> b -> c -> T3 a b c
T3 a
a b
b c
c) (\(T3 a
a b
b c
c) -> (a
a,b
b,c
c))
  {-# inline strict #-}

instance Strict (a,b,c,d) (T4 a b c d) where
  strict :: p (T4 a b c d) (f (T4 a b c d)) -> p (a, b, c, d) (f (a, b, c, d))
strict = ((a, b, c, d) -> T4 a b c d)
-> (T4 a b c d -> (a, b, c, d)) -> Iso' (a, b, c, d) (T4 a b c d)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(a
a,b
b,c
c,d
d) -> a -> b -> c -> d -> T4 a b c d
forall a b c d. a -> b -> c -> d -> T4 a b c d
T4 a
a b
b c
c d
d) (\(T4 a
a b
b c
c d
d) -> (a
a,b
b,c
c,d
d))
  {-# inline strict #-}

instance Strict (a,b,c,d,e) (T5 a b c d e) where
  strict :: p (T5 a b c d e) (f (T5 a b c d e))
-> p (a, b, c, d, e) (f (a, b, c, d, e))
strict = ((a, b, c, d, e) -> T5 a b c d e)
-> (T5 a b c d e -> (a, b, c, d, e))
-> Iso' (a, b, c, d, e) (T5 a b c d e)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(a
a,b
b,c
c,d
d,e
e) -> a -> b -> c -> d -> e -> T5 a b c d e
forall a b c d e. a -> b -> c -> d -> e -> T5 a b c d e
T5 a
a b
b c
c d
d e
e) (\(T5 a
a b
b c
c d
d e
e) -> (a
a,b
b,c
c,d
d,e
e))
  {-# inline strict #-}

instance Strict (a,b,c,d,e,f) (T6 a b c d e f) where
  strict :: p (T6 a b c d e f) (f (T6 a b c d e f))
-> p (a, b, c, d, e, f) (f (a, b, c, d, e, f))
strict = ((a, b, c, d, e, f) -> T6 a b c d e f)
-> (T6 a b c d e f -> (a, b, c, d, e, f))
-> Iso' (a, b, c, d, e, f) (T6 a b c d e f)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(a
a,b
b,c
c,d
d,e
e,f
f) -> a -> b -> c -> d -> e -> f -> T6 a b c d e f
forall a b c d e f. a -> b -> c -> d -> e -> f -> T6 a b c d e f
T6 a
a b
b c
c d
d e
e f
f) (\(T6 a
a b
b c
c d
d e
e f
f) -> (a
a,b
b,c
c,d
d,e
e,f
f))
  {-# inline strict #-}

instance Strict (a,b,c,d,e,f,g) (T7 a b c d e f g) where
  strict :: p (T7 a b c d e f g) (f (T7 a b c d e f g))
-> p (a, b, c, d, e, f, g) (f (a, b, c, d, e, f, g))
strict = ((a, b, c, d, e, f, g) -> T7 a b c d e f g)
-> (T7 a b c d e f g -> (a, b, c, d, e, f, g))
-> Iso' (a, b, c, d, e, f, g) (T7 a b c d e f g)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(a
a,b
b,c
c,d
d,e
e,f
f,g
g) -> a -> b -> c -> d -> e -> f -> g -> T7 a b c d e f g
forall a b c d e f g.
a -> b -> c -> d -> e -> f -> g -> T7 a b c d e f g
T7 a
a b
b c
c d
d e
e f
f g
g) (\(T7 a
a b
b c
c d
d e
e f
f g
g) -> (a
a,b
b,c
c,d
d,e
e,f
f,g
g))
  {-# inline strict #-}

instance Strict (a,b,c,d,e,f,g,h) (T8 a b c d e f g h) where
  strict :: p (T8 a b c d e f g h) (f (T8 a b c d e f g h))
-> p (a, b, c, d, e, f, g, h) (f (a, b, c, d, e, f, g, h))
strict = ((a, b, c, d, e, f, g, h) -> T8 a b c d e f g h)
-> (T8 a b c d e f g h -> (a, b, c, d, e, f, g, h))
-> Iso' (a, b, c, d, e, f, g, h) (T8 a b c d e f g h)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h) -> a -> b -> c -> d -> e -> f -> g -> h -> T8 a b c d e f g h
forall a b c d e f g h.
a -> b -> c -> d -> e -> f -> g -> h -> T8 a b c d e f g h
T8 a
a b
b c
c d
d e
e f
f g
g h
h) (\(T8 a
a b
b c
c d
d e
e f
f g
g h
h) -> (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h))
  {-# inline strict #-}

instance Strict (a,b,c,d,e,f,g,h,i) (T9 a b c d e f g h i) where
  strict :: p (T9 a b c d e f g h i) (f (T9 a b c d e f g h i))
-> p (a, b, c, d, e, f, g, h, i) (f (a, b, c, d, e, f, g, h, i))
strict = ((a, b, c, d, e, f, g, h, i) -> T9 a b c d e f g h i)
-> (T9 a b c d e f g h i -> (a, b, c, d, e, f, g, h, i))
-> Iso' (a, b, c, d, e, f, g, h, i) (T9 a b c d e f g h i)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
    (\(a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> T9 a b c d e f g h i
forall a b c d e f g h i.
a -> b -> c -> d -> e -> f -> g -> h -> i -> T9 a b c d e f g h i
T9 a
a b
b c
c d
d e
e f
f g
g h
h i
i)
    (\(T9 a
a b
b c
c d
d e
e f
f g
g h
h i
i) -> (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i))
  {-# inline strict #-}