{-# LANGUAGE AllowAmbiguousTypes        #-}
{-# LANGUAGE Arrows                     #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE GADTs                      #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeFamilies               #-}
{-# LANGUAGE TypeSynonymInstances       #-}

module Graphics.GPipe.Internal.Uniform where

import           Control.Arrow                    (Arrow (arr),
                                                   Kleisli (Kleisli), returnA,
                                                   (>>>))
import           Control.Category                 (Category)
import           Control.Monad.Trans.Class        (lift)
import           Control.Monad.Trans.Reader       (Reader, ask, runReader)
import           Control.Monad.Trans.Writer       (WriterT (runWriterT), tell)
import           Data.IORef                       (readIORef)
import           Data.Int                         (Int32)
import qualified Data.IntMap.Polymorphic          as Map
import           Data.IntMap.Polymorphic.Lazy     (insert)
import           Data.Text.Lazy                   (Text)
import           Data.Word                        (Word32)
import           Graphics.GL.Core45
import           Graphics.GPipe.Internal.Buffer   (B (..), B2 (..), B3 (..),
                                                   B4 (..), BInput (..),
                                                   Buffer (..), BufferFormat,
                                                   Uniform (..), makeBuffer)
import           Graphics.GPipe.Internal.Compiler (Binding,
                                                   RenderIOState (uniformNameToRenderIO))
import           Graphics.GPipe.Internal.Expr     (ExprM, GlobDeclM, S (S),
                                                   SType (..), stypeName,
                                                   stypeSize, tellGlobal,
                                                   tellGlobalLn, tshow,
                                                   useUniform, vec2S'', vec3S'',
                                                   vec4S'')
import           Graphics.GPipe.Internal.IDs      (UniformId (..))
import           Graphics.GPipe.Internal.Shader   (Shader (..), ShaderM,
                                                   askUniformAlignment,
                                                   getNewName, modifyRenderIO)
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 (..))

-- | This class constraints which buffer types can be loaded as uniforms, and what type those values have.
class BufferFormat a => UniformInput a where
    -- | The type the buffer value will be turned into once it becomes a vertex or fragment value (the @x@ parameter is either 'V' or 'F').
    type UniformFormat a x
    -- | An arrow action that turns a value from it's buffer representation to it's vertex or fragment representation. Use 'toUniform' from
    --   the GPipe provided instances to operate in this arrow. Also note that this arrow needs to be able to return a value
    --   lazily, so ensure you use
    --
    --  @proc ~pattern -> do ...@.
    toUniform :: ToUniform x a (UniformFormat a x)

-- | Load a uniform value from a 'Buffer' into a 'Shader'. The argument function
-- is used to retrieve the buffer and the index into this buffer from the shader
-- environment. UBO are obviously used here and there is no way to use "classic"
-- uniform.
getUniform :: forall os s b x. (UniformInput b) => (s -> (Buffer os (Uniform b), Int)) -> Shader os s (UniformFormat b x)
getUniform :: (s -> (Buffer os (Uniform b), Int))
-> Shader os s (UniformFormat b x)
getUniform s -> (Buffer os (Uniform b), Int)
sf = ShaderM s (UniformFormat b x) -> Shader os s (UniformFormat b x)
forall os s a. ShaderM s a -> Shader os s a
Shader (ShaderM s (UniformFormat b x) -> Shader os s (UniformFormat b x))
-> ShaderM s (UniformFormat b x) -> Shader os s (UniformFormat b x)
forall a b. (a -> b) -> a -> b
$ do
    Int
uniAl <- ShaderM s Int
forall s. ShaderM s Int
askUniformAlignment
    UniformId
blockId <- Int -> UniformId
UniformId (Int -> UniformId) -> ShaderM s Int -> ShaderM s UniformId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShaderM s Int
forall s. ShaderM s Int
getNewName
    let (UniformFormat b x
u, OffsetToSType
offToStype) = (Int -> ExprM Text) -> (UniformFormat b x, OffsetToSType)
shaderGen (GlobDeclM () -> UniformId -> Int -> ExprM Text
useUniform (OffsetToSType -> GlobDeclM ()
buildUDecl OffsetToSType
offToStype) UniformId
blockId)
        sampleBuffer :: Buffer os (Uniform b)
sampleBuffer = BufferName -> Int -> Int -> Buffer os (Uniform b)
forall os b.
BufferFormat b =>
BufferName -> Int -> Int -> Buffer os b
makeBuffer BufferName
forall a. HasCallStack => a
undefined Int
forall a. HasCallStack => a
undefined Int
uniAl :: Buffer os (Uniform b)
        shaderGen :: (Int -> ExprM Text) -> (UniformFormat b x, OffsetToSType) -- Int is name of uniform block
        shaderGen :: (Int -> ExprM Text) -> (UniformFormat b x, OffsetToSType)
shaderGen = Reader (Int -> ExprM Text) (UniformFormat b x, OffsetToSType)
-> (Int -> ExprM Text) -> (UniformFormat b x, OffsetToSType)
forall r a. Reader r a -> r -> a
runReader (Reader (Int -> ExprM Text) (UniformFormat b x, OffsetToSType)
 -> (Int -> ExprM Text) -> (UniformFormat b x, OffsetToSType))
-> Reader (Int -> ExprM Text) (UniformFormat b x, OffsetToSType)
-> (Int -> ExprM Text)
-> (UniformFormat b x, OffsetToSType)
forall a b. (a -> b) -> a -> b
$ WriterT
  OffsetToSType (Reader (Int -> ExprM Text)) (UniformFormat b x)
-> Reader (Int -> ExprM Text) (UniformFormat b x, OffsetToSType)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
runWriterT (WriterT
   OffsetToSType (Reader (Int -> ExprM Text)) (UniformFormat b x)
 -> Reader (Int -> ExprM Text) (UniformFormat b x, OffsetToSType))
-> WriterT
     OffsetToSType (Reader (Int -> ExprM Text)) (UniformFormat b x)
-> Reader (Int -> ExprM Text) (UniformFormat b x, OffsetToSType)
forall a b. (a -> b) -> a -> b
$ b
-> WriterT
     OffsetToSType (Reader (Int -> ExprM Text)) (UniformFormat b x)
shaderGenF (b
 -> WriterT
      OffsetToSType (Reader (Int -> ExprM Text)) (UniformFormat b x))
-> b
-> WriterT
     OffsetToSType (Reader (Int -> ExprM Text)) (UniformFormat b x)
forall a b. (a -> b) -> a -> b
$ Uniform b -> b
forall a. Uniform a -> a
fromBUnifom (Uniform b -> b) -> Uniform b -> b
forall a b. (a -> b) -> a -> b
$ Buffer os (Uniform b) -> BInput -> Uniform b
forall os b. Buffer os b -> BInput -> b
bufBElement Buffer os (Uniform b)
sampleBuffer (BInput -> Uniform b) -> BInput -> Uniform b
forall a b. (a -> b) -> a -> b
$ Int -> Int -> BInput
BInput Int
0 Int
0
    UniformId -> (s -> Int -> IO ()) -> ShaderM s ()
doForUniform UniformId
blockId ((s -> Int -> IO ()) -> ShaderM s ())
-> (s -> Int -> IO ()) -> ShaderM s ()
forall a b. (a -> b) -> a -> b
$ \s
s Int
bind ->
        let (Buffer os (Uniform b)
ub, Int
i) = s -> (Buffer os (Uniform b), Int)
sf s
s
        in  if Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 Bool -> Bool -> Bool
|| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Buffer os (Uniform b) -> Int
forall os b. Buffer os b -> Int
bufferLength Buffer os (Uniform b)
ub
            then [Char] -> IO ()
forall a. HasCallStack => [Char] -> a
error [Char]
"toUniformBlock, uniform buffer offset out of bounds"
            else do
                GLuint
bname <- BufferName -> IO GLuint
forall a. IORef a -> IO a
readIORef (BufferName -> IO GLuint) -> BufferName -> IO GLuint
forall a b. (a -> b) -> a -> b
$ Buffer os (Uniform b) -> BufferName
forall os b. Buffer os b -> BufferName
bufName Buffer os (Uniform b)
ub
                GLuint -> GLuint -> GLuint -> GLintptr -> GLintptr -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLuint -> GLuint -> GLuint -> GLintptr -> GLintptr -> m ()
glBindBufferRange GLuint
forall a. (Eq a, Num a) => a
GL_UNIFORM_BUFFER (Int -> GLuint
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
bind) GLuint
bname (Int -> GLintptr
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> GLintptr) -> Int -> GLintptr
forall a b. (a -> b) -> a -> b
$ Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* Buffer os (Uniform b) -> Int
forall os b. Buffer os b -> Int
bufElementSize Buffer os (Uniform b)
ub) (Int -> GLintptr
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> GLintptr) -> Int -> GLintptr
forall a b. (a -> b) -> a -> b
$ Buffer os (Uniform b) -> Int
forall os b. Buffer os b -> Int
bufElementSize Buffer os (Uniform b)
ub)
    UniformFormat b x -> ShaderM s (UniformFormat b x)
forall (m :: * -> *) a. Monad m => a -> m a
return UniformFormat b x
u

    where
        ToUniform (Kleisli b
-> WriterT
     OffsetToSType (Reader (Int -> ExprM Text)) (UniformFormat b x)
shaderGenF) = ToUniform x b (UniformFormat b x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform :: ToUniform x b (UniformFormat b x)
        fromBUnifom :: Uniform a -> a
fromBUnifom (Uniform a
b) = a
b

        doForUniform :: UniformId -> (s -> Binding -> IO()) -> ShaderM s ()
        doForUniform :: UniformId -> (s -> Int -> IO ()) -> ShaderM s ()
doForUniform UniformId
n s -> Int -> IO ()
io = (RenderIOState s -> RenderIOState s) -> ShaderM s ()
forall s. (RenderIOState s -> RenderIOState s) -> ShaderM s ()
modifyRenderIO (\RenderIOState s
s -> RenderIOState s
s { uniformNameToRenderIO :: IntMap UniformId (s -> Int -> IO ())
uniformNameToRenderIO = UniformId
-> (s -> Int -> IO ())
-> IntMap UniformId (s -> Int -> IO ())
-> IntMap UniformId (s -> Int -> IO ())
forall k v. Integral k => k -> v -> IntMap k v -> IntMap k v
insert UniformId
n s -> Int -> IO ()
io (RenderIOState s -> IntMap UniformId (s -> Int -> IO ())
forall s. RenderIOState s -> IntMap UniformId (s -> Int -> IO ())
uniformNameToRenderIO RenderIOState s
s) } )

buildUDecl :: OffsetToSType -> GlobDeclM ()
buildUDecl :: OffsetToSType -> GlobDeclM ()
buildUDecl = Int -> [(Int, SType)] -> GlobDeclM ()
buildUDecl' Int
0 ([(Int, SType)] -> GlobDeclM ())
-> (OffsetToSType -> [(Int, SType)])
-> OffsetToSType
-> GlobDeclM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OffsetToSType -> [(Int, SType)]
forall k v. Integral k => IntMap k v -> [(k, v)]
Map.toAscList where
    buildUDecl' :: Int -> [(Int, SType)] -> GlobDeclM ()
buildUDecl' Int
p xxs :: [(Int, SType)]
xxs@((Int
off, SType
stype):[(Int, SType)]
xs)
        | Int
off Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
p = do
            Text -> GlobDeclM ()
tellGlobal (Text -> GlobDeclM ()) -> Text -> GlobDeclM ()
forall a b. (a -> b) -> a -> b
$ SType -> Text
stypeName SType
stype
            Text -> GlobDeclM ()
tellGlobal Text
" u"
            Text -> GlobDeclM ()
tellGlobalLn (Text -> GlobDeclM ()) -> Text -> GlobDeclM ()
forall a b. (a -> b) -> a -> b
$ Int -> Text
forall a. Show a => a -> Text
tshow Int
off
            Int -> [(Int, SType)] -> GlobDeclM ()
buildUDecl' (Int
p Int -> Int -> Int
forall a. Num a => a -> a -> a
+ SType -> Int
stypeSize SType
stype) [(Int, SType)]
xs
        | Int
off Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
p = do
            Text -> GlobDeclM ()
tellGlobal Text
"float pad"
            Text -> GlobDeclM ()
tellGlobalLn (Text -> GlobDeclM ()) -> Text -> GlobDeclM ()
forall a b. (a -> b) -> a -> b
$ Int -> Text
forall a. Show a => a -> Text
tshow Int
p
            Int -> [(Int, SType)] -> GlobDeclM ()
buildUDecl' (Int
p Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4) [(Int, SType)]
xxs
        | Bool
otherwise =
            [Char] -> GlobDeclM ()
forall a. HasCallStack => [Char] -> a
error [Char]
"buildUDecl: Expected all offsets to be multiple of 4"
    buildUDecl' Int
_ [] = () -> GlobDeclM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

type OffsetToSType = Map.IntMap Int SType

-- | The arrow type for 'toUniform'.
newtype ToUniform x a b = ToUniform (Kleisli (WriterT OffsetToSType (Reader (Int -> ExprM Text))) a b) deriving (ToUniform x a a
ToUniform x b c -> ToUniform x a b -> ToUniform x a c
(forall a. ToUniform x a a)
-> (forall b c a.
    ToUniform x b c -> ToUniform x a b -> ToUniform x a c)
-> Category (ToUniform x)
forall a. ToUniform x a a
forall x a. ToUniform x a a
forall b c a. ToUniform x b c -> ToUniform x a b -> ToUniform x a c
forall x b c a.
ToUniform x b c -> ToUniform x a b -> ToUniform x a c
forall k (cat :: k -> k -> *).
(forall (a :: k). cat a a)
-> (forall (b :: k) (c :: k) (a :: k).
    cat b c -> cat a b -> cat a c)
-> Category cat
. :: ToUniform x b c -> ToUniform x a b -> ToUniform x a c
$c. :: forall x b c a.
ToUniform x b c -> ToUniform x a b -> ToUniform x a c
id :: ToUniform x a a
$cid :: forall x a. ToUniform x a a
Category, Category (ToUniform x)
Category (ToUniform x)
-> (forall b c. (b -> c) -> ToUniform x b c)
-> (forall b c d. ToUniform x b c -> ToUniform x (b, d) (c, d))
-> (forall b c d. ToUniform x b c -> ToUniform x (d, b) (d, c))
-> (forall b c b' c'.
    ToUniform x b c
    -> ToUniform x b' c' -> ToUniform x (b, b') (c, c'))
-> (forall b c c'.
    ToUniform x b c -> ToUniform x b c' -> ToUniform x b (c, c'))
-> Arrow (ToUniform x)
ToUniform x b c -> ToUniform x (b, d) (c, d)
ToUniform x b c -> ToUniform x (d, b) (d, c)
ToUniform x b c -> ToUniform x b' c' -> ToUniform x (b, b') (c, c')
ToUniform x b c -> ToUniform x b c' -> ToUniform x b (c, c')
(b -> c) -> ToUniform x b c
forall x. Category (ToUniform x)
forall b c. (b -> c) -> ToUniform x b c
forall b c d. ToUniform x b c -> ToUniform x (b, d) (c, d)
forall b c d. ToUniform x b c -> ToUniform x (d, b) (d, c)
forall b c c'.
ToUniform x b c -> ToUniform x b c' -> ToUniform x b (c, c')
forall x b c. (b -> c) -> ToUniform x b c
forall x b c d. ToUniform x b c -> ToUniform x (b, d) (c, d)
forall x b c d. ToUniform x b c -> ToUniform x (d, b) (d, c)
forall x b c c'.
ToUniform x b c -> ToUniform x b c' -> ToUniform x b (c, c')
forall b c b' c'.
ToUniform x b c -> ToUniform x b' c' -> ToUniform x (b, b') (c, c')
forall x b c b' c'.
ToUniform x b c -> ToUniform x b' c' -> ToUniform x (b, b') (c, c')
forall (a :: * -> * -> *).
Category a
-> (forall b c. (b -> c) -> a b c)
-> (forall b c d. a b c -> a (b, d) (c, d))
-> (forall b c d. a b c -> a (d, b) (d, c))
-> (forall b c b' c'. a b c -> a b' c' -> a (b, b') (c, c'))
-> (forall b c c'. a b c -> a b c' -> a b (c, c'))
-> Arrow a
&&& :: ToUniform x b c -> ToUniform x b c' -> ToUniform x b (c, c')
$c&&& :: forall x b c c'.
ToUniform x b c -> ToUniform x b c' -> ToUniform x b (c, c')
*** :: ToUniform x b c -> ToUniform x b' c' -> ToUniform x (b, b') (c, c')
$c*** :: forall x b c b' c'.
ToUniform x b c -> ToUniform x b' c' -> ToUniform x (b, b') (c, c')
second :: ToUniform x b c -> ToUniform x (d, b) (d, c)
$csecond :: forall x b c d. ToUniform x b c -> ToUniform x (d, b) (d, c)
first :: ToUniform x b c -> ToUniform x (b, d) (c, d)
$cfirst :: forall x b c d. ToUniform x b c -> ToUniform x (b, d) (c, d)
arr :: (b -> c) -> ToUniform x b c
$carr :: forall x b c. (b -> c) -> ToUniform x b c
$cp1Arrow :: forall x. Category (ToUniform x)
Arrow)

makeUniform :: SType -> ToUniform x (B a) (S x b)
makeUniform :: SType -> ToUniform x (B a) (S x b)
makeUniform SType
styp = Kleisli
  (WriterT OffsetToSType (Reader (Int -> ExprM Text))) (B a) (S x b)
-> ToUniform x (B a) (S x b)
forall x a b.
Kleisli (WriterT OffsetToSType (Reader (Int -> ExprM Text))) a b
-> ToUniform x a b
ToUniform (Kleisli
   (WriterT OffsetToSType (Reader (Int -> ExprM Text))) (B a) (S x b)
 -> ToUniform x (B a) (S x b))
-> Kleisli
     (WriterT OffsetToSType (Reader (Int -> ExprM Text))) (B a) (S x b)
-> ToUniform x (B a) (S x b)
forall a b. (a -> b) -> a -> b
$ (B a -> WriterT OffsetToSType (Reader (Int -> ExprM Text)) (S x b))
-> Kleisli
     (WriterT OffsetToSType (Reader (Int -> ExprM Text))) (B a) (S x b)
forall (m :: * -> *) a b. (a -> m b) -> Kleisli m a b
Kleisli ((B a
  -> WriterT OffsetToSType (Reader (Int -> ExprM Text)) (S x b))
 -> Kleisli
      (WriterT OffsetToSType (Reader (Int -> ExprM Text))) (B a) (S x b))
-> (B a
    -> WriterT OffsetToSType (Reader (Int -> ExprM Text)) (S x b))
-> Kleisli
     (WriterT OffsetToSType (Reader (Int -> ExprM Text))) (B a) (S x b)
forall a b. (a -> b) -> a -> b
$ \B a
bIn -> do
    let offset :: Int
offset = B a -> Int
forall a. B a -> Int
bOffset B a
bIn
    OffsetToSType
-> WriterT OffsetToSType (Reader (Int -> ExprM Text)) ()
forall (m :: * -> *) w. Monad m => w -> WriterT w m ()
tell (OffsetToSType
 -> WriterT OffsetToSType (Reader (Int -> ExprM Text)) ())
-> OffsetToSType
-> WriterT OffsetToSType (Reader (Int -> ExprM Text)) ()
forall a b. (a -> b) -> a -> b
$ Int -> SType -> OffsetToSType
forall k v. Integral k => k -> v -> IntMap k v
Map.singleton Int
offset SType
styp
    Int -> ExprM Text
useF <- ReaderT (Int -> ExprM Text) Identity (Int -> ExprM Text)
-> WriterT
     OffsetToSType (Reader (Int -> ExprM Text)) (Int -> ExprM Text)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ReaderT (Int -> ExprM Text) Identity (Int -> ExprM Text)
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
    S x b -> WriterT OffsetToSType (Reader (Int -> ExprM Text)) (S x b)
forall (m :: * -> *) a. Monad m => a -> m a
return (S x b
 -> WriterT OffsetToSType (Reader (Int -> ExprM Text)) (S x b))
-> S x b
-> WriterT OffsetToSType (Reader (Int -> ExprM Text)) (S x b)
forall a b. (a -> b) -> a -> b
$ ExprM Text -> S x b
forall x a. ExprM Text -> S x a
S (ExprM Text -> S x b) -> ExprM Text -> S x b
forall a b. (a -> b) -> a -> b
$ Int -> ExprM Text
useF Int
offset

instance UniformInput (B Float) where
    type UniformFormat (B Float) x = (S x Float)
    toUniform :: ToUniform x (B Float) (UniformFormat (B Float) x)
toUniform = SType -> ToUniform x (B Float) (S x Float)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform SType
STypeFloat

instance UniformInput (B Int32) where
    type UniformFormat (B Int32) x = (S x Int)
    toUniform :: ToUniform x (B Int32) (UniformFormat (B Int32) x)
toUniform = SType -> ToUniform x (B Int32) (S x Int)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform SType
STypeInt

instance UniformInput (B Word32) where
    type UniformFormat (B Word32) x = (S x Word)
    toUniform :: ToUniform x (B GLuint) (UniformFormat (B GLuint) x)
toUniform = SType -> ToUniform x (B GLuint) (S x Word)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform SType
STypeUInt

instance UniformInput (B2 Float) where
    type UniformFormat (B2 Float) x = V2 (S x Float)
    toUniform :: ToUniform x (B2 Float) (UniformFormat (B2 Float) x)
toUniform = (B2 Float -> B Float) -> ToUniform x (B2 Float) (B Float)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B2 Float -> B Float
forall a. B2 a -> B a
unB2 ToUniform x (B2 Float) (B Float)
-> ToUniform x (B Float) (V2 (S x Float))
-> ToUniform x (B2 Float) (V2 (S x Float))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B Float) (S x Float)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeVec Int
2) ToUniform x (B Float) (S x Float)
-> ToUniform x (S x Float) (V2 (S x Float))
-> ToUniform x (B Float) (V2 (S x Float))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Float -> V2 (S x Float))
-> ToUniform x (S x Float) (V2 (S x Float))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Float -> V2 (S x Float)
forall c a. S c a -> V2 (S c a)
vec2S''

instance UniformInput (B2 Int32) where
    type UniformFormat (B2 Int32) x = V2 (S x Int)
    toUniform :: ToUniform x (B2 Int32) (UniformFormat (B2 Int32) x)
toUniform = (B2 Int32 -> B Int32) -> ToUniform x (B2 Int32) (B Int32)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B2 Int32 -> B Int32
forall a. B2 a -> B a
unB2 ToUniform x (B2 Int32) (B Int32)
-> ToUniform x (B Int32) (V2 (S x Int))
-> ToUniform x (B2 Int32) (V2 (S x Int))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B Int32) (S x Int)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeIVec Int
2) ToUniform x (B Int32) (S x Int)
-> ToUniform x (S x Int) (V2 (S x Int))
-> ToUniform x (B Int32) (V2 (S x Int))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Int -> V2 (S x Int)) -> ToUniform x (S x Int) (V2 (S x Int))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Int -> V2 (S x Int)
forall c a. S c a -> V2 (S c a)
vec2S''

instance UniformInput (B2 Word32) where
    type UniformFormat (B2 Word32) x = V2 (S x Word)
    toUniform :: ToUniform x (B2 GLuint) (UniformFormat (B2 GLuint) x)
toUniform = (B2 GLuint -> B GLuint) -> ToUniform x (B2 GLuint) (B GLuint)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B2 GLuint -> B GLuint
forall a. B2 a -> B a
unB2 ToUniform x (B2 GLuint) (B GLuint)
-> ToUniform x (B GLuint) (V2 (S x Word))
-> ToUniform x (B2 GLuint) (V2 (S x Word))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B GLuint) (S x Word)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeVec Int
2) ToUniform x (B GLuint) (S x Word)
-> ToUniform x (S x Word) (V2 (S x Word))
-> ToUniform x (B GLuint) (V2 (S x Word))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Word -> V2 (S x Word))
-> ToUniform x (S x Word) (V2 (S x Word))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Word -> V2 (S x Word)
forall c a. S c a -> V2 (S c a)
vec2S''

instance UniformInput (B3 Float) where
    type UniformFormat (B3 Float) x = V3 (S x Float)
    toUniform :: ToUniform x (B3 Float) (UniformFormat (B3 Float) x)
toUniform = (B3 Float -> B Float) -> ToUniform x (B3 Float) (B Float)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B3 Float -> B Float
forall a. B3 a -> B a
unB3 ToUniform x (B3 Float) (B Float)
-> ToUniform x (B Float) (V3 (S x Float))
-> ToUniform x (B3 Float) (V3 (S x Float))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B Float) (S x Float)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeVec Int
3) ToUniform x (B Float) (S x Float)
-> ToUniform x (S x Float) (V3 (S x Float))
-> ToUniform x (B Float) (V3 (S x Float))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Float -> V3 (S x Float))
-> ToUniform x (S x Float) (V3 (S x Float))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Float -> V3 (S x Float)
forall c a. S c a -> V3 (S c a)
vec3S''

instance UniformInput (B3 Int32) where
    type UniformFormat (B3 Int32) x = V3 (S x Int)
    toUniform :: ToUniform x (B3 Int32) (UniformFormat (B3 Int32) x)
toUniform = (B3 Int32 -> B Int32) -> ToUniform x (B3 Int32) (B Int32)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B3 Int32 -> B Int32
forall a. B3 a -> B a
unB3 ToUniform x (B3 Int32) (B Int32)
-> ToUniform x (B Int32) (V3 (S x Int))
-> ToUniform x (B3 Int32) (V3 (S x Int))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B Int32) (S x Int)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeIVec Int
3) ToUniform x (B Int32) (S x Int)
-> ToUniform x (S x Int) (V3 (S x Int))
-> ToUniform x (B Int32) (V3 (S x Int))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Int -> V3 (S x Int)) -> ToUniform x (S x Int) (V3 (S x Int))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Int -> V3 (S x Int)
forall c a. S c a -> V3 (S c a)
vec3S''

instance UniformInput (B3 Word32) where
    type UniformFormat (B3 Word32) x = V3 (S x Word)
    toUniform :: ToUniform x (B3 GLuint) (UniformFormat (B3 GLuint) x)
toUniform = (B3 GLuint -> B GLuint) -> ToUniform x (B3 GLuint) (B GLuint)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B3 GLuint -> B GLuint
forall a. B3 a -> B a
unB3 ToUniform x (B3 GLuint) (B GLuint)
-> ToUniform x (B GLuint) (V3 (S x Word))
-> ToUniform x (B3 GLuint) (V3 (S x Word))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B GLuint) (S x Word)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeVec Int
3) ToUniform x (B GLuint) (S x Word)
-> ToUniform x (S x Word) (V3 (S x Word))
-> ToUniform x (B GLuint) (V3 (S x Word))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Word -> V3 (S x Word))
-> ToUniform x (S x Word) (V3 (S x Word))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Word -> V3 (S x Word)
forall c a. S c a -> V3 (S c a)
vec3S''

instance UniformInput (B4 Float) where
    type UniformFormat (B4 Float) x = V4 (S x Float)
    toUniform :: ToUniform x (B4 Float) (UniformFormat (B4 Float) x)
toUniform = (B4 Float -> B Float) -> ToUniform x (B4 Float) (B Float)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B4 Float -> B Float
forall a. B4 a -> B a
unB4 ToUniform x (B4 Float) (B Float)
-> ToUniform x (B Float) (V4 (S x Float))
-> ToUniform x (B4 Float) (V4 (S x Float))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B Float) (S x Float)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeVec Int
4) ToUniform x (B Float) (S x Float)
-> ToUniform x (S x Float) (V4 (S x Float))
-> ToUniform x (B Float) (V4 (S x Float))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Float -> V4 (S x Float))
-> ToUniform x (S x Float) (V4 (S x Float))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Float -> V4 (S x Float)
forall c a. S c a -> V4 (S c a)
vec4S''

instance UniformInput (B4 Int32) where
    type UniformFormat (B4 Int32) x = V4 (S x Int)
    toUniform :: ToUniform x (B4 Int32) (UniformFormat (B4 Int32) x)
toUniform = (B4 Int32 -> B Int32) -> ToUniform x (B4 Int32) (B Int32)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B4 Int32 -> B Int32
forall a. B4 a -> B a
unB4 ToUniform x (B4 Int32) (B Int32)
-> ToUniform x (B Int32) (V4 (S x Int))
-> ToUniform x (B4 Int32) (V4 (S x Int))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B Int32) (S x Int)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeIVec Int
4) ToUniform x (B Int32) (S x Int)
-> ToUniform x (S x Int) (V4 (S x Int))
-> ToUniform x (B Int32) (V4 (S x Int))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Int -> V4 (S x Int)) -> ToUniform x (S x Int) (V4 (S x Int))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Int -> V4 (S x Int)
forall c a. S c a -> V4 (S c a)
vec4S''

instance UniformInput (B4 Word32) where
    type UniformFormat (B4 Word32) x = V4 (S x Word)
    toUniform :: ToUniform x (B4 GLuint) (UniformFormat (B4 GLuint) x)
toUniform = (B4 GLuint -> B GLuint) -> ToUniform x (B4 GLuint) (B GLuint)
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr B4 GLuint -> B GLuint
forall a. B4 a -> B a
unB4 ToUniform x (B4 GLuint) (B GLuint)
-> ToUniform x (B GLuint) (V4 (S x Word))
-> ToUniform x (B4 GLuint) (V4 (S x Word))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> SType -> ToUniform x (B GLuint) (S x Word)
forall x a b. SType -> ToUniform x (B a) (S x b)
makeUniform (Int -> SType
STypeVec Int
4) ToUniform x (B GLuint) (S x Word)
-> ToUniform x (S x Word) (V4 (S x Word))
-> ToUniform x (B GLuint) (V4 (S x Word))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (S x Word -> V4 (S x Word))
-> ToUniform x (S x Word) (V4 (S x Word))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr S x Word -> V4 (S x Word)
forall c a. S c a -> V4 (S c a)
vec4S''


instance UniformInput a => UniformInput (V0 a) where
    type UniformFormat (V0 a) x = V0 (UniformFormat a x)
    toUniform :: ToUniform x (V0 a) (UniformFormat (V0 a) x)
toUniform = (V0 a -> V0 (UniformFormat a x))
-> ToUniform x (V0 a) (V0 (UniformFormat a x))
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (V0 (UniformFormat a x) -> V0 a -> V0 (UniformFormat a x)
forall a b. a -> b -> a
const V0 (UniformFormat a x)
forall a. V0 a
V0)

instance UniformInput a => UniformInput (V1 a) where
    type UniformFormat (V1 a) x = V1 (UniformFormat a x)
    toUniform :: ToUniform x (V1 a) (UniformFormat (V1 a) x)
toUniform = proc ~(V1 a
a) -> do
        UniformFormat a x
a' <- ToUniform x a (UniformFormat a x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a
a
        ToUniform x (V1 (UniformFormat a x)) (UniformFormat (V1 a) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< UniformFormat a x -> V1 (UniformFormat a x)
forall a. a -> V1 a
V1 UniformFormat a x
a'

instance UniformInput a => UniformInput (V2 a) where
    type UniformFormat (V2 a) x = V2 (UniformFormat a x)
    toUniform :: ToUniform x (V2 a) (UniformFormat (V2 a) x)
toUniform = proc ~(V2 a
a a
b) -> do
        UniformFormat a x
a' <- ToUniform x a (UniformFormat a x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a
a
        UniformFormat a x
b' <- ToUniform x a (UniformFormat a x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a
b
        ToUniform x (V2 (UniformFormat a x)) (UniformFormat (V2 a) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< UniformFormat a x -> UniformFormat a x -> V2 (UniformFormat a x)
forall a. a -> a -> V2 a
V2 UniformFormat a x
a' UniformFormat a x
b'

instance UniformInput a => UniformInput (V3 a) where
    type UniformFormat (V3 a) x = V3 (UniformFormat a x)
    toUniform :: ToUniform x (V3 a) (UniformFormat (V3 a) x)
toUniform = proc ~(V3 a
a a
b a
c) -> do
        V2 UniformFormat a x
a' UniformFormat a x
b' <- ToUniform x (V2 a) (V2 (UniformFormat a x))
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a -> a -> V2 a
forall a. a -> a -> V2 a
V2 a
a a
b
        UniformFormat a x
c' <- ToUniform x a (UniformFormat a x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a
c
        ToUniform x (V3 (UniformFormat a x)) (UniformFormat (V3 a) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< UniformFormat a x
-> UniformFormat a x -> UniformFormat a x -> V3 (UniformFormat a x)
forall a. a -> a -> a -> V3 a
V3 UniformFormat a x
a' UniformFormat a x
b' UniformFormat a x
c'

instance UniformInput a => UniformInput (V4 a)  where
    type UniformFormat (V4 a) x = V4 (UniformFormat a x)
    toUniform :: ToUniform x (V4 a) (UniformFormat (V4 a) x)
toUniform = proc ~(V4 a
a a
b a
c a
d) -> do
        V3 UniformFormat a x
a' UniformFormat a x
b' UniformFormat a x
c' <- ToUniform x (V3 a) (V3 (UniformFormat a x))
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a -> a -> a -> V3 a
forall a. a -> a -> a -> V3 a
V3 a
a a
b a
c
        UniformFormat a x
d' <- ToUniform x a (UniformFormat a x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a
d
        ToUniform x (V4 (UniformFormat a x)) (UniformFormat (V4 a) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< UniformFormat a x
-> UniformFormat a x
-> UniformFormat a x
-> UniformFormat a x
-> V4 (UniformFormat a x)
forall a. a -> a -> a -> a -> V4 a
V4 UniformFormat a x
a' UniformFormat a x
b' UniformFormat a x
c' UniformFormat a x
d'

instance UniformInput () where
    type UniformFormat () x = ()
    toUniform :: ToUniform x () (UniformFormat () x)
toUniform = (() -> ()) -> ToUniform x () ()
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (() -> () -> ()
forall a b. a -> b -> a
const ())

instance (UniformInput a, UniformInput b) => UniformInput (a,b) where
    type UniformFormat (a,b) x = (UniformFormat a x, UniformFormat b x)
    toUniform :: ToUniform x (a, b) (UniformFormat (a, b) x)
toUniform = proc ~(a
a,b
b) -> do
        UniformFormat a x
a' <- ToUniform x a (UniformFormat a x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< a
a
        UniformFormat b x
b' <- ToUniform x b (UniformFormat b x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< b
b
        ToUniform
  x (UniformFormat a x, UniformFormat b x) (UniformFormat (a, b) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< (UniformFormat a x
a', UniformFormat b x
b')

instance (UniformInput a, UniformInput b, UniformInput c) => UniformInput (a,b,c) where
    type UniformFormat (a,b,c) x = (UniformFormat a x, UniformFormat b x, UniformFormat c x)
    toUniform :: ToUniform x (a, b, c) (UniformFormat (a, b, c) x)
toUniform = proc ~(a
a,b
b,c
c) -> do
        (UniformFormat a x
a', UniformFormat b x
b') <- ToUniform x (a, b) (UniformFormat a x, UniformFormat b x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< (a
a, b
b)
        UniformFormat c x
c' <- ToUniform x c (UniformFormat c x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< c
c
        ToUniform
  x
  (UniformFormat a x, UniformFormat b x, UniformFormat c x)
  (UniformFormat (a, b, c) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< (UniformFormat a x
a', UniformFormat b x
b', UniformFormat c x
c')

instance (UniformInput a, UniformInput b, UniformInput c, UniformInput d) => UniformInput (a,b,c,d) where
    type UniformFormat (a,b,c,d) x = (UniformFormat a x, UniformFormat b x, UniformFormat c x, UniformFormat d x)
    toUniform :: ToUniform x (a, b, c, d) (UniformFormat (a, b, c, d) x)
toUniform = proc ~(a
a,b
b,c
c,d
d) -> do
        (UniformFormat a x
a', UniformFormat b x
b', UniformFormat c x
c') <- ToUniform
  x
  (a, b, c)
  (UniformFormat a x, UniformFormat b x, UniformFormat c x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< (a
a, b
b, c
c)
        UniformFormat d x
d' <- ToUniform x d (UniformFormat d x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< d
d
        ToUniform
  x
  (UniformFormat a x, UniformFormat b x, UniformFormat c x,
   UniformFormat d x)
  (UniformFormat (a, b, c, d) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< (UniformFormat a x
a', UniformFormat b x
b', UniformFormat c x
c', UniformFormat d x
d')

instance (UniformInput a, UniformInput b, UniformInput c, UniformInput d, UniformInput e) => UniformInput (a,b,c,d,e) where
    type UniformFormat (a,b,c,d,e) x = (UniformFormat a x, UniformFormat b x, UniformFormat c x, UniformFormat d x, UniformFormat e x)
    toUniform :: ToUniform x (a, b, c, d, e) (UniformFormat (a, b, c, d, e) x)
toUniform = proc ~(a
a,b
b,c
c,d
d,e
e) -> do
        (UniformFormat a x
a',UniformFormat b x
b',UniformFormat c x
c',UniformFormat d x
d') <- ToUniform
  x
  (a, b, c, d)
  (UniformFormat a x, UniformFormat b x, UniformFormat c x,
   UniformFormat d x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< (a
a,b
b,c
c,d
d)
        UniformFormat e x
e' <- ToUniform x e (UniformFormat e x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< e
e
        ToUniform
  x
  (UniformFormat a x, UniformFormat b x, UniformFormat c x,
   UniformFormat d x, UniformFormat e x)
  (UniformFormat (a, b, c, d, e) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< (UniformFormat a x
a', UniformFormat b x
b', UniformFormat c x
c', UniformFormat d x
d', UniformFormat e x
e')

instance (UniformInput a, UniformInput b, UniformInput c, UniformInput d, UniformInput e, UniformInput f) => UniformInput (a,b,c,d,e,f) where
    type UniformFormat (a,b,c,d,e,f) x = (UniformFormat a x, UniformFormat b x, UniformFormat c x, UniformFormat d x, UniformFormat e x, UniformFormat f x)
    toUniform :: ToUniform x (a, b, c, d, e, f) (UniformFormat (a, b, c, d, e, f) x)
toUniform = proc ~(a
a,b
b,c
c,d
d,e
e,f
f) -> do
        (UniformFormat a x
a',UniformFormat b x
b',UniformFormat c x
c',UniformFormat d x
d',UniformFormat e x
e') <- ToUniform
  x
  (a, b, c, d, e)
  (UniformFormat a x, UniformFormat b x, UniformFormat c x,
   UniformFormat d x, UniformFormat e x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< (a
a,b
b,c
c,d
d,e
e)
        UniformFormat f x
f' <- ToUniform x f (UniformFormat f x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< f
f
        ToUniform
  x
  (UniformFormat a x, UniformFormat b x, UniformFormat c x,
   UniformFormat d x, UniformFormat e x, UniformFormat f x)
  (UniformFormat (a, b, c, d, e, f) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< (UniformFormat a x
a', UniformFormat b x
b', UniformFormat c x
c', UniformFormat d x
d', UniformFormat e x
e', UniformFormat f x
f')

instance (UniformInput a, UniformInput b, UniformInput c, UniformInput d, UniformInput e, UniformInput f, UniformInput g) => UniformInput (a,b,c,d,e,f,g) where
    type UniformFormat (a,b,c,d,e,f,g) x = (UniformFormat a x, UniformFormat b x, UniformFormat c x, UniformFormat d x, UniformFormat e x, UniformFormat f x, UniformFormat g x)
    toUniform :: ToUniform
  x (a, b, c, d, e, f, g) (UniformFormat (a, b, c, d, e, f, g) x)
toUniform = proc ~(a
a,b
b,c
c,d
d,e
e,f
f,g
g) -> do
        (UniformFormat a x
a',UniformFormat b x
b',UniformFormat c x
c',UniformFormat d x
d',UniformFormat e x
e',UniformFormat f x
f') <- ToUniform
  x
  (a, b, c, d, e, f)
  (UniformFormat a x, UniformFormat b x, UniformFormat c x,
   UniformFormat d x, UniformFormat e x, UniformFormat f x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< (a
a,b
b,c
c,d
d,e
e,f
f)
        UniformFormat g x
g' <- ToUniform x g (UniformFormat g x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< g
g
        ToUniform
  x
  (UniformFormat a x, UniformFormat b x, UniformFormat c x,
   UniformFormat d x, UniformFormat e x, UniformFormat f x,
   UniformFormat g x)
  (UniformFormat (a, b, c, d, e, f, g) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< (UniformFormat a x
a', UniformFormat b x
b', UniformFormat c x
c', UniformFormat d x
d', UniformFormat e x
e', UniformFormat f x
f', UniformFormat g x
g')

instance UniformInput a => UniformInput (Quaternion a) where
    type UniformFormat (Quaternion a) x = Quaternion (UniformFormat a x)
    toUniform :: ToUniform x (Quaternion a) (UniformFormat (Quaternion a) x)
toUniform = proc ~(Quaternion a
a V3 a
v) -> do
        (UniformFormat a x
a',V3 (UniformFormat a x)
v') <- ToUniform x (a, V3 a) (UniformFormat a x, V3 (UniformFormat a x))
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< (a
a,V3 a
v)
        ToUniform
  x (Quaternion (UniformFormat a x)) (UniformFormat (Quaternion a) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< UniformFormat a x
-> V3 (UniformFormat a x) -> Quaternion (UniformFormat a x)
forall a. a -> V3 a -> Quaternion a
Quaternion UniformFormat a x
a' V3 (UniformFormat a x)
v'

instance UniformInput a => UniformInput (Plucker a) where
    type UniformFormat (Plucker a) x = Plucker (UniformFormat a x)
    toUniform :: ToUniform x (Plucker a) (UniformFormat (Plucker a) x)
toUniform = proc ~(Plucker a
a a
b a
c a
d a
e a
f) -> do
        (UniformFormat a x
a',UniformFormat a x
b',UniformFormat a x
c',UniformFormat a x
d',UniformFormat a x
e',UniformFormat a x
f') <- ToUniform
  x
  (a, a, a, a, a, a)
  (UniformFormat a x, UniformFormat a x, UniformFormat a x,
   UniformFormat a x, UniformFormat a x, UniformFormat a x)
forall a x. UniformInput a => ToUniform x a (UniformFormat a x)
toUniform -< (a
a,a
b,a
c,a
d,a
e,a
f)
        ToUniform
  x (Plucker (UniformFormat a x)) (UniformFormat (Plucker a) x)
forall (a :: * -> * -> *) b. Arrow a => a b b
returnA -< UniformFormat a x
-> UniformFormat a x
-> UniformFormat a x
-> UniformFormat a x
-> UniformFormat a x
-> UniformFormat a x
-> Plucker (UniformFormat a x)
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker UniformFormat a x
a' UniformFormat a x
b' UniformFormat a x
c' UniformFormat a x
d' UniformFormat a x
e' UniformFormat a x
f'