{-# OPTIONS_GHC -Wall -fno-warn-orphans #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}

module Accessors.Instances () where

import Control.Compose ( (:.)(..), Id(..), unO, unId )
import Control.Lens ( Lens' )
import qualified Linear
import GHC.Word
import Data.Int
import Foreign.C.Types
import SpatialMath ( Euler )
import SpatialMathT ( V3T(..), Rot(..) )

import Accessors.Accessors ( Lookup(..), GAData(..), GAConstructor(..), GAField(..) )

-- tuple instances
instance (Lookup a, Lookup b) => Lookup (a, b) where
  toAccessorTree :: Lens' b (a, b) -> AccessorTree b
toAccessorTree Lens' b (a, b)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$
    String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"(,)" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$
    String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"(,)"
    [ (String -> Maybe String
forall a. a -> Maybe a
Just String
"(x,_)", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b) -> f (a, b)) -> b -> f b
Lens' b (a, b)
lens0 (((a, b) -> f (a, b)) -> b -> f b)
-> ((a -> f a) -> (a, b) -> f (a, b)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> (a, b) -> f (a, b)
forall a b. Lens' (a, b) a
lens1))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"(_,x)", Lens' b b -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b) -> f (a, b)) -> b -> f b
Lens' b (a, b)
lens0 (((a, b) -> f (a, b)) -> b -> f b)
-> ((b -> f b) -> (a, b) -> f (a, b)) -> (b -> f b) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> f b) -> (a, b) -> f (a, b)
forall a b. Lens' (a, b) b
lens2))
    ]
    where
      lens1 ::  Lens' (a, b) a
      lens1 :: (a -> f a) -> (a, b) -> f (a, b)
lens1 a -> f a
f (a
x, b
y) = (a -> (a, b)) -> f a -> f (a, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
x' -> (a
x', b
y)) (a -> f a
f a
x)

      lens2 :: Lens' (a, b) b
      lens2 :: (b -> f b) -> (a, b) -> f (a, b)
lens2 b -> f b
f (a
x, b
y) = (b -> (a, b)) -> f b -> f (a, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\b
y' -> (a
x, b
y')) (b -> f b
f b
y)

instance (Lookup a, Lookup b, Lookup c) => Lookup (a, b, c) where
  toAccessorTree :: Lens' b (a, b, c) -> AccessorTree b
toAccessorTree Lens' b (a, b, c)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$
    String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"(,,)" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$
    String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"(,,)"
    [ (String -> Maybe String
forall a. a -> Maybe a
Just String
"(x,_,_)", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b, c) -> f (a, b, c)) -> b -> f b
Lens' b (a, b, c)
lens0 (((a, b, c) -> f (a, b, c)) -> b -> f b)
-> ((a -> f a) -> (a, b, c) -> f (a, b, c))
-> (a -> f a)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> (a, b, c) -> f (a, b, c)
forall a b c. Lens' (a, b, c) a
lens1))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"(_,x,_)", Lens' b b -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b, c) -> f (a, b, c)) -> b -> f b
Lens' b (a, b, c)
lens0 (((a, b, c) -> f (a, b, c)) -> b -> f b)
-> ((b -> f b) -> (a, b, c) -> f (a, b, c))
-> (b -> f b)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> f b) -> (a, b, c) -> f (a, b, c)
forall a b c. Lens' (a, b, c) b
lens2))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"(_,_,x)", Lens' b c -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b, c) -> f (a, b, c)) -> b -> f b
Lens' b (a, b, c)
lens0 (((a, b, c) -> f (a, b, c)) -> b -> f b)
-> ((c -> f c) -> (a, b, c) -> f (a, b, c))
-> (c -> f c)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c -> f c) -> (a, b, c) -> f (a, b, c)
forall a b c. Lens' (a, b, c) c
lens3))
    ]
    where
      lens1 ::  Lens' (a, b, c) a
      lens1 :: (a -> f a) -> (a, b, c) -> f (a, b, c)
lens1 a -> f a
f (a
x, b
y, c
z) = (a -> (a, b, c)) -> f a -> f (a, b, c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
x' -> (a
x', b
y, c
z)) (a -> f a
f a
x)
      lens2 :: Lens' (a, b, c) b
      lens2 :: (b -> f b) -> (a, b, c) -> f (a, b, c)
lens2 b -> f b
f (a
x, b
y, c
z) = (b -> (a, b, c)) -> f b -> f (a, b, c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\b
y' -> (a
x, b
y', c
z)) (b -> f b
f b
y)
      lens3 :: Lens' (a, b, c) c
      lens3 :: (c -> f c) -> (a, b, c) -> f (a, b, c)
lens3 c -> f c
f (a
x, b
y, c
z) = (c -> (a, b, c)) -> f c -> f (a, b, c)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\c
z' -> (a
x, b
y, c
z')) (c -> f c
f c
z)

instance (Lookup a, Lookup b, Lookup c, Lookup d) => Lookup (a, b, c, d) where
  toAccessorTree :: Lens' b (a, b, c, d) -> AccessorTree b
toAccessorTree Lens' b (a, b, c, d)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$
    String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"(,,,)" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$
    String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"(,,,)"
    [ (String -> Maybe String
forall a. a -> Maybe a
Just String
"(x,_,_,_)", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b
Lens' b (a, b, c, d)
lens0 (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b)
-> ((a -> f a) -> (a, b, c, d) -> f (a, b, c, d))
-> (a -> f a)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> (a, b, c, d) -> f (a, b, c, d)
forall a b c d. Lens' (a, b, c, d) a
lens1))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"(_,x,_,_)", Lens' b b -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b
Lens' b (a, b, c, d)
lens0 (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b)
-> ((b -> f b) -> (a, b, c, d) -> f (a, b, c, d))
-> (b -> f b)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> f b) -> (a, b, c, d) -> f (a, b, c, d)
forall a b c d. Lens' (a, b, c, d) b
lens2))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"(_,_,x,_)", Lens' b c -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b
Lens' b (a, b, c, d)
lens0 (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b)
-> ((c -> f c) -> (a, b, c, d) -> f (a, b, c, d))
-> (c -> f c)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c -> f c) -> (a, b, c, d) -> f (a, b, c, d)
forall a b c d. Lens' (a, b, c, d) c
lens3))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"(_,_,_,x)", Lens' b d -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b
Lens' b (a, b, c, d)
lens0 (((a, b, c, d) -> f (a, b, c, d)) -> b -> f b)
-> ((d -> f d) -> (a, b, c, d) -> f (a, b, c, d))
-> (d -> f d)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (d -> f d) -> (a, b, c, d) -> f (a, b, c, d)
forall a b c d. Lens' (a, b, c, d) d
lens4))
    ]
    where
      lens1 ::  Lens' (a, b, c, d) a
      lens1 :: (a -> f a) -> (a, b, c, d) -> f (a, b, c, d)
lens1 a -> f a
f (a
x, b
y, c
z, d
w) = (a -> (a, b, c, d)) -> f a -> f (a, b, c, d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
x' -> (a
x', b
y, c
z, d
w)) (a -> f a
f a
x)
      lens2 :: Lens' (a, b, c, d) b
      lens2 :: (b -> f b) -> (a, b, c, d) -> f (a, b, c, d)
lens2 b -> f b
f (a
x, b
y, c
z, d
w) = (b -> (a, b, c, d)) -> f b -> f (a, b, c, d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\b
y' -> (a
x, b
y', c
z, d
w)) (b -> f b
f b
y)
      lens3 :: Lens' (a, b, c, d) c
      lens3 :: (c -> f c) -> (a, b, c, d) -> f (a, b, c, d)
lens3 c -> f c
f (a
x, b
y, c
z, d
w) = (c -> (a, b, c, d)) -> f c -> f (a, b, c, d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\c
z' -> (a
x, b
y, c
z', d
w)) (c -> f c
f c
z)
      lens4 :: Lens' (a, b, c, d) d
      lens4 :: (d -> f d) -> (a, b, c, d) -> f (a, b, c, d)
lens4 d -> f d
f (a
x, b
y, c
z, d
w) = (d -> (a, b, c, d)) -> f d -> f (a, b, c, d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\d
w' -> (a
x, b
y, c
z, d
w')) (d -> f d
f d
w)

-- TODO(MP): Product?  Const?  Identity?

-- some instance from linear
instance Lookup (Linear.V0 a) where
  toAccessorTree :: Lens' b (V0 a) -> AccessorTree b
toAccessorTree Lens' b (V0 a)
_ =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$ String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"V0" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$ String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"V0" []
instance Lookup a => Lookup (Linear.V1 a) where
  toAccessorTree :: Lens' b (V1 a) -> AccessorTree b
toAccessorTree Lens' b (V1 a)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$ String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"V1" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$ String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"V1"
    [(String -> Maybe String
forall a. a -> Maybe a
Just String
"x", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V1 a -> f (V1 a)) -> b -> f b
Lens' b (V1 a)
lens0 ((V1 a -> f (V1 a)) -> b -> f b)
-> ((a -> f a) -> V1 a -> f (V1 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V1 a -> f (V1 a)
forall (t :: * -> *) a. R1 t => Lens' (t a) a
Linear._x))]

instance Lookup a => Lookup (Linear.V2 a) where
  toAccessorTree :: Lens' b (V2 a) -> AccessorTree b
toAccessorTree Lens' b (V2 a)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$ String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"V2" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$ String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"V2"
    [ (String -> Maybe String
forall a. a -> Maybe a
Just String
"x", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V2 a -> f (V2 a)) -> b -> f b
Lens' b (V2 a)
lens0 ((V2 a -> f (V2 a)) -> b -> f b)
-> ((a -> f a) -> V2 a -> f (V2 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V2 a -> f (V2 a)
forall (t :: * -> *) a. R1 t => Lens' (t a) a
Linear._x))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"y", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V2 a -> f (V2 a)) -> b -> f b
Lens' b (V2 a)
lens0 ((V2 a -> f (V2 a)) -> b -> f b)
-> ((a -> f a) -> V2 a -> f (V2 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V2 a -> f (V2 a)
forall (t :: * -> *) a. R2 t => Lens' (t a) a
Linear._y))
    ]

instance Lookup a => Lookup (Linear.V3 a) where
  toAccessorTree :: Lens' b (V3 a) -> AccessorTree b
toAccessorTree Lens' b (V3 a)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$ String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"V3" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$ String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"V3"
    [ (String -> Maybe String
forall a. a -> Maybe a
Just String
"x", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V3 a -> f (V3 a)) -> b -> f b
Lens' b (V3 a)
lens0 ((V3 a -> f (V3 a)) -> b -> f b)
-> ((a -> f a) -> V3 a -> f (V3 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V3 a -> f (V3 a)
forall (t :: * -> *) a. R1 t => Lens' (t a) a
Linear._x))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"y", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V3 a -> f (V3 a)) -> b -> f b
Lens' b (V3 a)
lens0 ((V3 a -> f (V3 a)) -> b -> f b)
-> ((a -> f a) -> V3 a -> f (V3 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V3 a -> f (V3 a)
forall (t :: * -> *) a. R2 t => Lens' (t a) a
Linear._y))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"z", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V3 a -> f (V3 a)) -> b -> f b
Lens' b (V3 a)
lens0 ((V3 a -> f (V3 a)) -> b -> f b)
-> ((a -> f a) -> V3 a -> f (V3 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V3 a -> f (V3 a)
forall (t :: * -> *) a. R3 t => Lens' (t a) a
Linear._z))
    ]
instance Lookup a => Lookup (Linear.V4 a) where
  toAccessorTree :: Lens' b (V4 a) -> AccessorTree b
toAccessorTree Lens' b (V4 a)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$ String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"V4" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$ String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"V4"
    [ (String -> Maybe String
forall a. a -> Maybe a
Just String
"x", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V4 a -> f (V4 a)) -> b -> f b
Lens' b (V4 a)
lens0 ((V4 a -> f (V4 a)) -> b -> f b)
-> ((a -> f a) -> V4 a -> f (V4 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V4 a -> f (V4 a)
forall (t :: * -> *) a. R1 t => Lens' (t a) a
Linear._x))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"y", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V4 a -> f (V4 a)) -> b -> f b
Lens' b (V4 a)
lens0 ((V4 a -> f (V4 a)) -> b -> f b)
-> ((a -> f a) -> V4 a -> f (V4 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V4 a -> f (V4 a)
forall (t :: * -> *) a. R2 t => Lens' (t a) a
Linear._y))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"z", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V4 a -> f (V4 a)) -> b -> f b
Lens' b (V4 a)
lens0 ((V4 a -> f (V4 a)) -> b -> f b)
-> ((a -> f a) -> V4 a -> f (V4 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V4 a -> f (V4 a)
forall (t :: * -> *) a. R3 t => Lens' (t a) a
Linear._z))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"w", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V4 a -> f (V4 a)) -> b -> f b
Lens' b (V4 a)
lens0 ((V4 a -> f (V4 a)) -> b -> f b)
-> ((a -> f a) -> V4 a -> f (V4 a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> V4 a -> f (V4 a)
forall (t :: * -> *) a. R4 t => Lens' (t a) a
Linear._w))
    ]
instance Lookup a => Lookup (Linear.Quaternion a) where
  toAccessorTree :: Lens' b (Quaternion a) -> AccessorTree b
toAccessorTree Lens' b (Quaternion a)
lens0 =
    GAData b -> AccessorTree b
forall a b. b -> Either a b
Right (GAData b -> AccessorTree b) -> GAData b -> AccessorTree b
forall a b. (a -> b) -> a -> b
$ String -> GAConstructor b -> GAData b
forall a. String -> GAConstructor a -> GAData a
GAData String
"Quaternion" (GAConstructor b -> GAData b) -> GAConstructor b -> GAData b
forall a b. (a -> b) -> a -> b
$ String -> [(Maybe String, AccessorTree b)] -> GAConstructor b
forall a.
String -> [(Maybe String, AccessorTree a)] -> GAConstructor a
GAConstructor String
"Quaternion"
    [ (String -> Maybe String
forall a. a -> Maybe a
Just String
"q0", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((Quaternion a -> f (Quaternion a)) -> b -> f b
Lens' b (Quaternion a)
lens0 ((Quaternion a -> f (Quaternion a)) -> b -> f b)
-> ((a -> f a) -> Quaternion a -> f (Quaternion a))
-> (a -> f a)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> Quaternion a -> f (Quaternion a)
forall (t :: * -> *) a. Complicated t => Lens' (t a) a
Linear._e))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"q1", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((Quaternion a -> f (Quaternion a)) -> b -> f b
Lens' b (Quaternion a)
lens0 ((Quaternion a -> f (Quaternion a)) -> b -> f b)
-> ((a -> f a) -> Quaternion a -> f (Quaternion a))
-> (a -> f a)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> Quaternion a -> f (Quaternion a)
forall (t :: * -> *) a. Complicated t => Lens' (t a) a
Linear._i))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"q2", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((Quaternion a -> f (Quaternion a)) -> b -> f b
Lens' b (Quaternion a)
lens0 ((Quaternion a -> f (Quaternion a)) -> b -> f b)
-> ((a -> f a) -> Quaternion a -> f (Quaternion a))
-> (a -> f a)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> Quaternion a -> f (Quaternion a)
forall (t :: * -> *) a. Hamiltonian t => Lens' (t a) a
Linear._j))
    , (String -> Maybe String
forall a. a -> Maybe a
Just String
"q3", Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((Quaternion a -> f (Quaternion a)) -> b -> f b
Lens' b (Quaternion a)
lens0 ((Quaternion a -> f (Quaternion a)) -> b -> f b)
-> ((a -> f a) -> Quaternion a -> f (Quaternion a))
-> (a -> f a)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f a) -> Quaternion a -> f (Quaternion a)
forall (t :: * -> *) a. Hamiltonian t => Lens' (t a) a
Linear._k))
    ]

-- basic types
instance Lookup () where
  toAccessorTree :: Lens' b () -> AccessorTree b
toAccessorTree Lens' b ()
_ = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left GAField b
forall a. GAField a
FieldUnit
instance Lookup Int8 where
  toAccessorTree :: Lens' b Int8 -> AccessorTree b
toAccessorTree Lens' b Int8
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int8 -> GAField b
forall a. Lens' a Int8 -> GAField a
FieldInt8 Lens' b Int8
lens)
instance Lookup Int16 where
  toAccessorTree :: Lens' b Int16 -> AccessorTree b
toAccessorTree Lens' b Int16
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int16 -> GAField b
forall a. Lens' a Int16 -> GAField a
FieldInt16 Lens' b Int16
lens)
instance Lookup Int32 where
  toAccessorTree :: Lens' b Int32 -> AccessorTree b
toAccessorTree Lens' b Int32
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int32 -> GAField b
forall a. Lens' a Int32 -> GAField a
FieldInt32 Lens' b Int32
lens)
instance Lookup Int64 where
  toAccessorTree :: Lens' b Int64 -> AccessorTree b
toAccessorTree Lens' b Int64
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 Lens' b Int64
lens)
instance Lookup Word8 where
  toAccessorTree :: Lens' b Word8 -> AccessorTree b
toAccessorTree Lens' b Word8
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word8 -> GAField b
forall a. Lens' a Word8 -> GAField a
FieldWord8 Lens' b Word8
lens)
instance Lookup Word16 where
  toAccessorTree :: Lens' b Word16 -> AccessorTree b
toAccessorTree Lens' b Word16
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word16 -> GAField b
forall a. Lens' a Word16 -> GAField a
FieldWord16 Lens' b Word16
lens)
instance Lookup Word32 where
  toAccessorTree :: Lens' b Word32 -> AccessorTree b
toAccessorTree Lens' b Word32
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word32 -> GAField b
forall a. Lens' a Word32 -> GAField a
FieldWord32 Lens' b Word32
lens)
instance Lookup Word64 where
  toAccessorTree :: Lens' b Word64 -> AccessorTree b
toAccessorTree Lens' b Word64
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word64 -> GAField b
forall a. Lens' a Word64 -> GAField a
FieldWord64 Lens' b Word64
lens)
instance Lookup Float where
  toAccessorTree :: Lens' b Float -> AccessorTree b
toAccessorTree Lens' b Float
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Float -> GAField b
forall a. Lens' a Float -> GAField a
FieldFloat Lens' b Float
lens)
instance Lookup Double where
  toAccessorTree :: Lens' b Double -> AccessorTree b
toAccessorTree Lens' b Double
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Double -> GAField b
forall a. Lens' a Double -> GAField a
FieldDouble Lens' b Double
lens)
instance Lookup Bool
instance Lookup String where
  toAccessorTree :: Lens' b String -> AccessorTree b
toAccessorTree Lens' b String
lens = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b String -> GAField b
forall a. Lens' a String -> GAField a
FieldString Lens' b String
lens)

-- Word types
instance Lookup Word where
  toAccessorTree :: Lens' b Word -> AccessorTree b
toAccessorTree Lens' b Word
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word64 -> GAField b
forall a. Lens' a Word64 -> GAField a
FieldWord64 ((Word -> f Word) -> b -> f b
Lens' b Word
lens0 ((Word -> f Word) -> b -> f b)
-> ((Word64 -> f Word64) -> Word -> f Word)
-> (Word64 -> f Word64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> f Word64) -> Word -> f Word
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))

-- Int types
instance Lookup Int where
  toAccessorTree :: Lens' b Int -> AccessorTree b
toAccessorTree Lens' b Int
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((Int -> f Int) -> b -> f b
Lens' b Int
lens0 ((Int -> f Int) -> b -> f b)
-> ((Int64 -> f Int64) -> Int -> f Int)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> Int -> f Int
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))

-- C types
-- todo(greg): some of these have inappropriate fields
instance Lookup CChar where
  toAccessorTree :: Lens' b CChar -> AccessorTree b
toAccessorTree Lens' b CChar
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int8 -> GAField b
forall a. Lens' a Int8 -> GAField a
FieldInt8 ((CChar -> f CChar) -> b -> f b
Lens' b CChar
lens0 ((CChar -> f CChar) -> b -> f b)
-> ((Int8 -> f Int8) -> CChar -> f CChar)
-> (Int8 -> f Int8)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int8 -> f Int8) -> CChar -> f CChar
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CSChar where
  toAccessorTree :: Lens' b CSChar -> AccessorTree b
toAccessorTree Lens' b CSChar
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int8 -> GAField b
forall a. Lens' a Int8 -> GAField a
FieldInt8 ((CSChar -> f CSChar) -> b -> f b
Lens' b CSChar
lens0 ((CSChar -> f CSChar) -> b -> f b)
-> ((Int8 -> f Int8) -> CSChar -> f CSChar)
-> (Int8 -> f Int8)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int8 -> f Int8) -> CSChar -> f CSChar
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CUChar where
  toAccessorTree :: Lens' b CUChar -> AccessorTree b
toAccessorTree Lens' b CUChar
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word8 -> GAField b
forall a. Lens' a Word8 -> GAField a
FieldWord8 ((CUChar -> f CUChar) -> b -> f b
Lens' b CUChar
lens0 ((CUChar -> f CUChar) -> b -> f b)
-> ((Word8 -> f Word8) -> CUChar -> f CUChar)
-> (Word8 -> f Word8)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> f Word8) -> CUChar -> f CUChar
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CShort where
  toAccessorTree :: Lens' b CShort -> AccessorTree b
toAccessorTree Lens' b CShort
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int16 -> GAField b
forall a. Lens' a Int16 -> GAField a
FieldInt16 ((CShort -> f CShort) -> b -> f b
Lens' b CShort
lens0 ((CShort -> f CShort) -> b -> f b)
-> ((Int16 -> f Int16) -> CShort -> f CShort)
-> (Int16 -> f Int16)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int16 -> f Int16) -> CShort -> f CShort
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CUShort where
  toAccessorTree :: Lens' b CUShort -> AccessorTree b
toAccessorTree Lens' b CUShort
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word16 -> GAField b
forall a. Lens' a Word16 -> GAField a
FieldWord16 ((CUShort -> f CUShort) -> b -> f b
Lens' b CUShort
lens0 ((CUShort -> f CUShort) -> b -> f b)
-> ((Word16 -> f Word16) -> CUShort -> f CUShort)
-> (Word16 -> f Word16)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word16 -> f Word16) -> CUShort -> f CUShort
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CInt where
  toAccessorTree :: Lens' b CInt -> AccessorTree b
toAccessorTree Lens' b CInt
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int32 -> GAField b
forall a. Lens' a Int32 -> GAField a
FieldInt32 ((CInt -> f CInt) -> b -> f b
Lens' b CInt
lens0 ((CInt -> f CInt) -> b -> f b)
-> ((Int32 -> f Int32) -> CInt -> f CInt)
-> (Int32 -> f Int32)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int32 -> f Int32) -> CInt -> f CInt
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CUInt where
  toAccessorTree :: Lens' b CUInt -> AccessorTree b
toAccessorTree Lens' b CUInt
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word32 -> GAField b
forall a. Lens' a Word32 -> GAField a
FieldWord32 ((CUInt -> f CUInt) -> b -> f b
Lens' b CUInt
lens0 ((CUInt -> f CUInt) -> b -> f b)
-> ((Word32 -> f Word32) -> CUInt -> f CUInt)
-> (Word32 -> f Word32)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> f Word32) -> CUInt -> f CUInt
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CLong where
  toAccessorTree :: Lens' b CLong -> AccessorTree b
toAccessorTree Lens' b CLong
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CLong -> f CLong) -> b -> f b
Lens' b CLong
lens0 ((CLong -> f CLong) -> b -> f b)
-> ((Int64 -> f Int64) -> CLong -> f CLong)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CLong -> f CLong
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CULong where
  toAccessorTree :: Lens' b CULong -> AccessorTree b
toAccessorTree Lens' b CULong
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word64 -> GAField b
forall a. Lens' a Word64 -> GAField a
FieldWord64 ((CULong -> f CULong) -> b -> f b
Lens' b CULong
lens0 ((CULong -> f CULong) -> b -> f b)
-> ((Word64 -> f Word64) -> CULong -> f CULong)
-> (Word64 -> f Word64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> f Word64) -> CULong -> f CULong
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CPtrdiff where
  toAccessorTree :: Lens' b CPtrdiff -> AccessorTree b
toAccessorTree Lens' b CPtrdiff
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CPtrdiff -> f CPtrdiff) -> b -> f b
Lens' b CPtrdiff
lens0 ((CPtrdiff -> f CPtrdiff) -> b -> f b)
-> ((Int64 -> f Int64) -> CPtrdiff -> f CPtrdiff)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CPtrdiff -> f CPtrdiff
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CSize where
  toAccessorTree :: Lens' b CSize -> AccessorTree b
toAccessorTree Lens' b CSize
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word64 -> GAField b
forall a. Lens' a Word64 -> GAField a
FieldWord64 ((CSize -> f CSize) -> b -> f b
Lens' b CSize
lens0 ((CSize -> f CSize) -> b -> f b)
-> ((Word64 -> f Word64) -> CSize -> f CSize)
-> (Word64 -> f Word64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> f Word64) -> CSize -> f CSize
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CWchar where
  toAccessorTree :: Lens' b CWchar -> AccessorTree b
toAccessorTree Lens' b CWchar
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int32 -> GAField b
forall a. Lens' a Int32 -> GAField a
FieldInt32 ((CWchar -> f CWchar) -> b -> f b
Lens' b CWchar
lens0 ((CWchar -> f CWchar) -> b -> f b)
-> ((Int32 -> f Int32) -> CWchar -> f CWchar)
-> (Int32 -> f Int32)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int32 -> f Int32) -> CWchar -> f CWchar
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CSigAtomic where
  toAccessorTree :: Lens' b CSigAtomic -> AccessorTree b
toAccessorTree Lens' b CSigAtomic
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int32 -> GAField b
forall a. Lens' a Int32 -> GAField a
FieldInt32 ((CSigAtomic -> f CSigAtomic) -> b -> f b
Lens' b CSigAtomic
lens0 ((CSigAtomic -> f CSigAtomic) -> b -> f b)
-> ((Int32 -> f Int32) -> CSigAtomic -> f CSigAtomic)
-> (Int32 -> f Int32)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int32 -> f Int32) -> CSigAtomic -> f CSigAtomic
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CLLong where
  toAccessorTree :: Lens' b CLLong -> AccessorTree b
toAccessorTree Lens' b CLLong
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CLLong -> f CLLong) -> b -> f b
Lens' b CLLong
lens0 ((CLLong -> f CLLong) -> b -> f b)
-> ((Int64 -> f Int64) -> CLLong -> f CLLong)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CLLong -> f CLLong
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CULLong where
  toAccessorTree :: Lens' b CULLong -> AccessorTree b
toAccessorTree Lens' b CULLong
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word64 -> GAField b
forall a. Lens' a Word64 -> GAField a
FieldWord64 ((CULLong -> f CULLong) -> b -> f b
Lens' b CULLong
lens0 ((CULLong -> f CULLong) -> b -> f b)
-> ((Word64 -> f Word64) -> CULLong -> f CULLong)
-> (Word64 -> f Word64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> f Word64) -> CULLong -> f CULLong
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CIntPtr where
  toAccessorTree :: Lens' b CIntPtr -> AccessorTree b
toAccessorTree Lens' b CIntPtr
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CIntPtr -> f CIntPtr) -> b -> f b
Lens' b CIntPtr
lens0 ((CIntPtr -> f CIntPtr) -> b -> f b)
-> ((Int64 -> f Int64) -> CIntPtr -> f CIntPtr)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CIntPtr -> f CIntPtr
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CUIntPtr where
  toAccessorTree :: Lens' b CUIntPtr -> AccessorTree b
toAccessorTree Lens' b CUIntPtr
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word64 -> GAField b
forall a. Lens' a Word64 -> GAField a
FieldWord64 ((CUIntPtr -> f CUIntPtr) -> b -> f b
Lens' b CUIntPtr
lens0 ((CUIntPtr -> f CUIntPtr) -> b -> f b)
-> ((Word64 -> f Word64) -> CUIntPtr -> f CUIntPtr)
-> (Word64 -> f Word64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> f Word64) -> CUIntPtr -> f CUIntPtr
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CIntMax where
  toAccessorTree :: Lens' b CIntMax -> AccessorTree b
toAccessorTree Lens' b CIntMax
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CIntMax -> f CIntMax) -> b -> f b
Lens' b CIntMax
lens0 ((CIntMax -> f CIntMax) -> b -> f b)
-> ((Int64 -> f Int64) -> CIntMax -> f CIntMax)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CIntMax -> f CIntMax
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CUIntMax where
  toAccessorTree :: Lens' b CUIntMax -> AccessorTree b
toAccessorTree Lens' b CUIntMax
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word64 -> GAField b
forall a. Lens' a Word64 -> GAField a
FieldWord64 ((CUIntMax -> f CUIntMax) -> b -> f b
Lens' b CUIntMax
lens0 ((CUIntMax -> f CUIntMax) -> b -> f b)
-> ((Word64 -> f Word64) -> CUIntMax -> f CUIntMax)
-> (Word64 -> f Word64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> f Word64) -> CUIntMax -> f CUIntMax
forall a b. (Integral a, Integral b) => Lens' a b
integralLens))
instance Lookup CClock where
  toAccessorTree :: Lens' b CClock -> AccessorTree b
toAccessorTree Lens' b CClock
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CClock -> f CClock) -> b -> f b
Lens' b CClock
lens0 ((CClock -> f CClock) -> b -> f b)
-> ((Int64 -> f Int64) -> CClock -> f CClock)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CClock -> f CClock
forall (f :: * -> *) a t.
(Functor f, Integral a, Num t) =>
(t -> f a) -> CClock -> f CClock
clockLens))
    where
      clockLens :: (t -> f a) -> CClock -> f CClock
clockLens t -> f a
f (CClock Int64
x) = (a -> CClock) -> f a -> f CClock
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int64 -> CClock
CClock (Int64 -> CClock) -> (a -> Int64) -> a -> CClock
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (t -> f a
f (Int64 -> t
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
x))
instance Lookup CTime where
  toAccessorTree :: Lens' b CTime -> AccessorTree b
toAccessorTree Lens' b CTime
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CTime -> f CTime) -> b -> f b
Lens' b CTime
lens0 ((CTime -> f CTime) -> b -> f b)
-> ((Int64 -> f Int64) -> CTime -> f CTime)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CTime -> f CTime
forall (f :: * -> *) a t.
(Functor f, Integral a, Num t) =>
(t -> f a) -> CTime -> f CTime
timeLens))
    where
      timeLens :: (t -> f a) -> CTime -> f CTime
timeLens t -> f a
f (CTime Int64
x) = (a -> CTime) -> f a -> f CTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int64 -> CTime
CTime (Int64 -> CTime) -> (a -> Int64) -> a -> CTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (t -> f a
f (Int64 -> t
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
x))
instance Lookup CUSeconds where
  toAccessorTree :: Lens' b CUSeconds -> AccessorTree b
toAccessorTree Lens' b CUSeconds
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Word32 -> GAField b
forall a. Lens' a Word32 -> GAField a
FieldWord32 ((CUSeconds -> f CUSeconds) -> b -> f b
Lens' b CUSeconds
lens0 ((CUSeconds -> f CUSeconds) -> b -> f b)
-> ((Word32 -> f Word32) -> CUSeconds -> f CUSeconds)
-> (Word32 -> f Word32)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> f Word32) -> CUSeconds -> f CUSeconds
forall (f :: * -> *) a t.
(Functor f, Integral a, Num t) =>
(t -> f a) -> CUSeconds -> f CUSeconds
usecondsLens))
    where
      usecondsLens :: (t -> f a) -> CUSeconds -> f CUSeconds
usecondsLens t -> f a
f (CUSeconds Word32
x) = (a -> CUSeconds) -> f a -> f CUSeconds
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Word32 -> CUSeconds
CUSeconds (Word32 -> CUSeconds) -> (a -> Word32) -> a -> CUSeconds
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (t -> f a
f (Word32 -> t
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
x))
instance Lookup CSUSeconds where
  toAccessorTree :: Lens' b CSUSeconds -> AccessorTree b
toAccessorTree Lens' b CSUSeconds
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Int64 -> GAField b
forall a. Lens' a Int64 -> GAField a
FieldInt64 ((CSUSeconds -> f CSUSeconds) -> b -> f b
Lens' b CSUSeconds
lens0 ((CSUSeconds -> f CSUSeconds) -> b -> f b)
-> ((Int64 -> f Int64) -> CSUSeconds -> f CSUSeconds)
-> (Int64 -> f Int64)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int64 -> f Int64) -> CSUSeconds -> f CSUSeconds
forall (f :: * -> *) a t.
(Functor f, Integral a, Num t) =>
(t -> f a) -> CSUSeconds -> f CSUSeconds
susecondsLens))
    where
      susecondsLens :: (t -> f a) -> CSUSeconds -> f CSUSeconds
susecondsLens t -> f a
f (CSUSeconds Int64
x) = (a -> CSUSeconds) -> f a -> f CSUSeconds
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int64 -> CSUSeconds
CSUSeconds (Int64 -> CSUSeconds) -> (a -> Int64) -> a -> CSUSeconds
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (t -> f a
f (Int64 -> t
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
x))
instance Lookup CFloat where
  toAccessorTree :: Lens' b CFloat -> AccessorTree b
toAccessorTree Lens' b CFloat
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Double -> GAField b
forall a. Lens' a Double -> GAField a
FieldDouble ((CFloat -> f CFloat) -> b -> f b
Lens' b CFloat
lens0 ((CFloat -> f CFloat) -> b -> f b)
-> ((Double -> f Double) -> CFloat -> f CFloat)
-> (Double -> f Double)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Double -> f Double) -> CFloat -> f CFloat
forall a. (Fractional a, Real a) => Lens' a Double
realFracLens))
instance Lookup CDouble where
  toAccessorTree :: Lens' b CDouble -> AccessorTree b
toAccessorTree Lens' b CDouble
lens0 = GAField b -> AccessorTree b
forall a b. a -> Either a b
Left (Lens' b Double -> GAField b
forall a. Lens' a Double -> GAField a
FieldDouble ((CDouble -> f CDouble) -> b -> f b
Lens' b CDouble
lens0 ((CDouble -> f CDouble) -> b -> f b)
-> ((Double -> f Double) -> CDouble -> f CDouble)
-> (Double -> f Double)
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Double -> f Double) -> CDouble -> f CDouble
forall a. (Fractional a, Real a) => Lens' a Double
realFracLens))

{-# INLINE integralLens #-}
integralLens :: (Integral a, Integral b) => Lens' a b
integralLens :: Lens' a b
integralLens b -> f b
f a
x = (b -> a) -> f b -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (b -> f b
f (a -> b
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
x))

{-# INLINE realFracLens #-}
realFracLens :: (Fractional a, Real a) => Lens' a Double
realFracLens :: Lens' a Double
realFracLens Double -> f Double
f a
x = (Double -> a) -> f Double -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Double -> a
forall a b. (Real a, Fractional b) => a -> b
realToFrac (Double -> f Double
f (a -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac a
x))

-- other types
instance Lookup a => Lookup (Id a) where
  toAccessorTree :: Lens' b (Id a) -> AccessorTree b
toAccessorTree Lens' b (Id a)
lens0 = Lens' b a -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((Id a -> f (Id a)) -> b -> f b
Lens' b (Id a)
lens0 ((Id a -> f (Id a)) -> b -> f b)
-> ((a -> f a) -> Id a -> f (Id a)) -> (a -> f a) -> b -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\a -> f a
f Id a
x -> (a -> Id a) -> f a -> f (Id a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Id a
forall a. a -> Id a
Id (a -> f a
f (Id a -> a
forall a. Id a -> a
unId Id a
x))))
instance Lookup (g (f a)) => Lookup ((g :. f) a) where
  toAccessorTree :: Lens' b ((:.) g f a) -> AccessorTree b
toAccessorTree Lens' b ((:.) g f a)
lens0 = Lens' b (g (f a)) -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree (((:.) g f a -> f ((:.) g f a)) -> b -> f b
Lens' b ((:.) g f a)
lens0 (((:.) g f a -> f ((:.) g f a)) -> b -> f b)
-> ((g (f a) -> f (g (f a))) -> (:.) g f a -> f ((:.) g f a))
-> (g (f a) -> f (g (f a)))
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\g (f a) -> f (g (f a))
f (:.) g f a
x -> (g (f a) -> (:.) g f a) -> f (g (f a)) -> f ((:.) g f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap g (f a) -> (:.) g f a
forall k2 k1 (g :: k2 -> *) (f :: k1 -> k2) (a :: k1).
g (f a) -> (:.) g f a
O (g (f a) -> f (g (f a))
f ((:.) g f a -> g (f a)
forall k2 k1 (g :: k2 -> *) (f :: k1 -> k2) (a :: k1).
(:.) g f a -> g (f a)
unO (:.) g f a
x))))
instance Lookup (g a) => Lookup (Rot f1 f2 g a) where
  toAccessorTree :: Lens' b (Rot f1 f2 g a) -> AccessorTree b
toAccessorTree Lens' b (Rot f1 f2 g a)
lens0 = Lens' b (g a) -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((Rot f1 f2 g a -> f (Rot f1 f2 g a)) -> b -> f b
Lens' b (Rot f1 f2 g a)
lens0 ((Rot f1 f2 g a -> f (Rot f1 f2 g a)) -> b -> f b)
-> ((g a -> f (g a)) -> Rot f1 f2 g a -> f (Rot f1 f2 g a))
-> (g a -> f (g a))
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\g a -> f (g a)
f Rot f1 f2 g a
x -> (g a -> Rot f1 f2 g a) -> f (g a) -> f (Rot f1 f2 g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap g a -> Rot f1 f2 g a
forall f1 f2 (r :: * -> *) a. r a -> Rot f1 f2 r a
Rot (g a -> f (g a)
f (Rot f1 f2 g a -> g a
forall f1 f2 (r :: * -> *) a. Rot f1 f2 r a -> r a
unRot Rot f1 f2 g a
x))))
instance Lookup a => Lookup (V3T f a) where
  toAccessorTree :: Lens' b (V3T f a) -> AccessorTree b
toAccessorTree Lens' b (V3T f a)
lens0 = Lens' b (V3 a) -> AccessorTree b
forall a b. Lookup a => Lens' b a -> AccessorTree b
toAccessorTree ((V3T f a -> f (V3T f a)) -> b -> f b
Lens' b (V3T f a)
lens0 ((V3T f a -> f (V3T f a)) -> b -> f b)
-> ((V3 a -> f (V3 a)) -> V3T f a -> f (V3T f a))
-> (V3 a -> f (V3 a))
-> b
-> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\V3 a -> f (V3 a)
f V3T f a
x -> (V3 a -> V3T f a) -> f (V3 a) -> f (V3T f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap V3 a -> V3T f a
forall f a. V3 a -> V3T f a
V3T (V3 a -> f (V3 a)
f (V3T f a -> V3 a
forall f a. V3T f a -> V3 a
unV V3T f a
x))))
instance Lookup a => Lookup (Euler a)