{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies     #-}
module Graphics.GPipe.Internal.Orphans where

import           Data.Boolean      (Boolean (false, true, (&&*), (||*)),
                                    BooleanOf, EqB (..), IfB (..))
import           Linear.Affine     (Point (..))
import           Linear.Plucker    (Plucker (..))
import           Linear.Quaternion (Quaternion (..))
import           Linear.V0         (V0 (..))
import           Linear.V1         (V1 (..))
import           Linear.V2         (V2 (..))
import           Linear.V3         (V3 (..))
import           Linear.V4         (V4 (..))

type instance BooleanOf (V0 a) = BooleanOf a
type instance BooleanOf (V1 a) = BooleanOf a
type instance BooleanOf (V2 a) = BooleanOf a
type instance BooleanOf (V3 a) = BooleanOf a
type instance BooleanOf (V4 a) = BooleanOf a
type instance BooleanOf (Plucker a) = BooleanOf a
type instance BooleanOf (Quaternion a) = BooleanOf a
type instance BooleanOf (Point f a) = BooleanOf (f a)

instance EqB a => EqB (V0 a) where
  V0 a
V0 ==* :: V0 a -> V0 a -> bool
==* V0 a
V0 = bool
forall b. Boolean b => b
true
  V0 a
V0 /=* :: V0 a -> V0 a -> bool
/=* V0 a
V0 = bool
forall b. Boolean b => b
false
instance EqB a => EqB (V1 a) where
  V1 a
a ==* :: V1 a -> V1 a -> bool
==* V1 a
x = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
x
  V1 a
a /=* :: V1 a -> V1 a -> bool
/=* V1 a
x = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
x
instance EqB a => EqB (V2 a) where
  V2 a
a a
b ==* :: V2 a -> V2 a -> bool
==* V2 a
x a
y = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
y
  V2 a
a a
b /=* :: V2 a -> V2 a -> bool
/=* V2 a
x a
y = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
y
instance EqB a => EqB (V3 a) where
  V3 a
a a
b a
c ==* :: V3 a -> V3 a -> bool
==* V3 a
x a
y a
z = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
y bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
c a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
z
  V3 a
a a
b a
c /=* :: V3 a -> V3 a -> bool
/=* V3 a
x a
y a
z = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
y bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
c a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
z
instance EqB a => EqB (V4 a) where
  V4 a
a a
b a
c a
d ==* :: V4 a -> V4 a -> bool
==* V4 a
x a
y a
z a
w = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
y bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
c a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
z bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
d a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
w
  V4 a
a a
b a
c a
d /=* :: V4 a -> V4 a -> bool
/=* V4 a
x a
y a
z a
w = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
y bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
c a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
z bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
d a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
w
instance EqB a => EqB (Quaternion a) where
  Quaternion a
a V3 a
v ==* :: Quaternion a -> Quaternion a -> bool
==* Quaternion a
b V3 a
u = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
b bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* V3 a
v V3 a -> V3 a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* V3 a
u
  Quaternion a
a V3 a
v /=* :: Quaternion a -> Quaternion a -> bool
/=* Quaternion a
b V3 a
u = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
b bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* V3 a
v V3 a -> V3 a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* V3 a
u
instance EqB a => EqB (Plucker a) where
  Plucker a
a a
b a
c a
d a
e a
f ==* :: Plucker a -> Plucker a -> bool
==* Plucker a
x a
y a
z a
w a
u a
v = a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
y bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
c a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
z bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
d a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
w bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
e a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
u bool -> bool -> bool
forall b. Boolean b => b -> b -> b
&&* a
f a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* a
v
  Plucker a
a a
b a
c a
d a
e a
f /=* :: Plucker a -> Plucker a -> bool
/=* Plucker a
x a
y a
z a
w a
u a
v= a
a a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
x bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
b a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
y bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
c a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
z bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
d a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
w bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
e a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
u bool -> bool -> bool
forall b. Boolean b => b -> b -> b
||* a
f a -> a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* a
v
instance EqB (f a) => EqB (Point f a) where
  P f a
a ==* :: Point f a -> Point f a -> bool
==* P f a
x = f a
a f a -> f a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* f a
x
  P f a
a /=* :: Point f a -> Point f a -> bool
/=* P f a
x = f a
a f a -> f a -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* f a
x

instance IfB a => IfB (V0 a) where
        ifB :: bool -> V0 a -> V0 a -> V0 a
ifB bool
q V0 a
_ V0 a
_ = V0 a
forall a. V0 a
V0
instance IfB a => IfB (V1 a) where
        ifB :: bool -> V1 a -> V1 a -> V1 a
ifB bool
q (V1 a
a) (V1 a
x) = a -> V1 a
forall a. a -> V1 a
V1 (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
a a
x)
instance IfB a => IfB (V2 a) where
        ifB :: bool -> V2 a -> V2 a -> V2 a
ifB bool
q (V2 a
a a
b) (V2 a
x a
y) = a -> a -> V2 a
forall a. a -> a -> V2 a
V2 (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
a a
x) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
b a
y)
instance IfB a => IfB (V3 a) where
        ifB :: bool -> V3 a -> V3 a -> V3 a
ifB bool
q (V3 a
a a
b a
c) (V3 a
x a
y a
z) = a -> a -> a -> V3 a
forall a. a -> a -> a -> V3 a
V3 (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
a a
x) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
b a
y) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
c a
z)
instance IfB a => IfB (V4 a) where
        ifB :: bool -> V4 a -> V4 a -> V4 a
ifB bool
q (V4 a
a a
b a
c a
d) (V4 a
x a
y a
z a
w) = a -> a -> a -> a -> V4 a
forall a. a -> a -> a -> a -> V4 a
V4 (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
a a
x) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
b a
y) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
c a
z) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
d a
w)
instance IfB a => IfB (Quaternion a) where
        ifB :: bool -> Quaternion a -> Quaternion a -> Quaternion a
ifB bool
q (Quaternion a
a V3 a
v) (Quaternion a
b V3 a
u) = a -> V3 a -> Quaternion a
forall a. a -> V3 a -> Quaternion a
Quaternion (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
a a
b) (bool -> V3 a -> V3 a -> V3 a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q V3 a
v V3 a
u)
instance IfB a => IfB (Plucker a) where
        ifB :: bool -> Plucker a -> Plucker a -> Plucker a
ifB bool
q (Plucker a
a a
b a
c a
d a
e a
f) (Plucker a
x a
y a
z a
w a
u a
v) = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
a a
x) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
b a
y) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
c a
z) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
d a
w) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
e a
u) (bool -> a -> a -> a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q a
f a
v)
instance IfB (f a) => IfB (Point f a) where
        ifB :: bool -> Point f a -> Point f a -> Point f a
ifB bool
q (P f a
a) (P f a
x) = f a -> Point f a
forall (f :: * -> *) a. f a -> Point f a
P (bool -> f a -> f a -> f a
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
q f a
a f a
x)