{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
module Geomancy.IVec4
( IVec4
, ivec4
, withIVec4
, pattern WithIVec4
, convert
, fromTuple
, dot
) where
import Control.DeepSeq (NFData(rnf))
import Data.Coerce (Coercible, coerce)
import Data.Int (Int32)
import Data.MonoTraversable (Element, MonoFunctor(..), MonoPointed(..))
import Foreign (Storable(..))
import Foreign.Ptr.Diff (peekDiffOff, pokeDiffOff)
import GHC.Ix (Ix(..))
import Geomancy.Elementwise (Elementwise(..))
import Graphics.Gl.Block (Block(..))
data IVec4 = IVec4
{-# UNPACK #-} !Int32
{-# UNPACK #-} !Int32
{-# UNPACK #-} !Int32
{-# UNPACK #-} !Int32
deriving (IVec4 -> IVec4 -> Bool
(IVec4 -> IVec4 -> Bool) -> (IVec4 -> IVec4 -> Bool) -> Eq IVec4
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IVec4 -> IVec4 -> Bool
== :: IVec4 -> IVec4 -> Bool
$c/= :: IVec4 -> IVec4 -> Bool
/= :: IVec4 -> IVec4 -> Bool
Eq, Eq IVec4
Eq IVec4 =>
(IVec4 -> IVec4 -> Ordering)
-> (IVec4 -> IVec4 -> Bool)
-> (IVec4 -> IVec4 -> Bool)
-> (IVec4 -> IVec4 -> Bool)
-> (IVec4 -> IVec4 -> Bool)
-> (IVec4 -> IVec4 -> IVec4)
-> (IVec4 -> IVec4 -> IVec4)
-> Ord IVec4
IVec4 -> IVec4 -> Bool
IVec4 -> IVec4 -> Ordering
IVec4 -> IVec4 -> IVec4
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: IVec4 -> IVec4 -> Ordering
compare :: IVec4 -> IVec4 -> Ordering
$c< :: IVec4 -> IVec4 -> Bool
< :: IVec4 -> IVec4 -> Bool
$c<= :: IVec4 -> IVec4 -> Bool
<= :: IVec4 -> IVec4 -> Bool
$c> :: IVec4 -> IVec4 -> Bool
> :: IVec4 -> IVec4 -> Bool
$c>= :: IVec4 -> IVec4 -> Bool
>= :: IVec4 -> IVec4 -> Bool
$cmax :: IVec4 -> IVec4 -> IVec4
max :: IVec4 -> IVec4 -> IVec4
$cmin :: IVec4 -> IVec4 -> IVec4
min :: IVec4 -> IVec4 -> IVec4
Ord, Int -> IVec4 -> ShowS
[IVec4] -> ShowS
IVec4 -> String
(Int -> IVec4 -> ShowS)
-> (IVec4 -> String) -> ([IVec4] -> ShowS) -> Show IVec4
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IVec4 -> ShowS
showsPrec :: Int -> IVec4 -> ShowS
$cshow :: IVec4 -> String
show :: IVec4 -> String
$cshowList :: [IVec4] -> ShowS
showList :: [IVec4] -> ShowS
Show)
{-# INLINE ivec4 #-}
ivec4 :: Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4 :: Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4 = Int32 -> Int32 -> Int32 -> Int32 -> IVec4
IVec4
{-# INLINE withIVec4 #-}
withIVec4
:: IVec4
-> (Int32 -> Int32 -> Int32 -> Int32 -> r)
-> r
withIVec4 :: forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 (IVec4 Int32
a Int32
b Int32
c Int32
d) Int32 -> Int32 -> Int32 -> Int32 -> r
f = Int32 -> Int32 -> Int32 -> Int32 -> r
f Int32
a Int32
b Int32
c Int32
d
pattern WithIVec4 :: Int32 -> Int32 -> Int32 -> Int32 -> IVec4
pattern $mWithIVec4 :: forall {r}.
IVec4
-> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> ((# #) -> r) -> r
WithIVec4 a b c d <- ((`withIVec4` (,,,)) -> (a, b, c, d))
{-# COMPLETE WithIVec4 #-}
{-# INLINE convert #-}
convert :: Coercible v IVec4 => (Int32 -> a) -> (a -> a -> a -> a -> r) -> v -> r
convert :: forall v a r.
Coercible v IVec4 =>
(Int32 -> a) -> (a -> a -> a -> a -> r) -> v -> r
convert Int32 -> a
f a -> a -> a -> a -> r
t v
v =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 (v -> IVec4
forall a b. Coercible a b => a -> b
coerce v
v) \Int32
a Int32
b Int32
c Int32
d ->
a -> a -> a -> a -> r
t (Int32 -> a
f Int32
a) (Int32 -> a
f Int32
b) (Int32 -> a
f Int32
c) (Int32 -> a
f Int32
d)
{-# INLINE fromTuple #-}
fromTuple :: (Int32, Int32, Int32, Int32) -> IVec4
fromTuple :: (Int32, Int32, Int32, Int32) -> IVec4
fromTuple (Int32
x, Int32
y, Int32
z, Int32
w) = Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4 Int32
x Int32
y Int32
z Int32
w
{-# INLINE dot #-}
dot :: IVec4 -> IVec4 -> Int32
dot :: IVec4 -> IVec4 -> Int32
dot (IVec4 Int32
l1 Int32
l2 Int32
l3 Int32
l4) (IVec4 Int32
r1 Int32
r2 Int32
r3 Int32
r4) =
Int32
l1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
l2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
l3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
l4 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r4
instance NFData IVec4 where
rnf :: IVec4 -> ()
rnf IVec4{} = ()
type instance Element IVec4 = Int32
instance MonoFunctor IVec4 where
{-# INLINE omap #-}
omap :: (Element IVec4 -> Element IVec4) -> IVec4 -> IVec4
omap Element IVec4 -> Element IVec4
f IVec4
v =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
v \Int32
x Int32
y Int32
z Int32
w ->
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4 (Element IVec4 -> Element IVec4
f Int32
Element IVec4
x) (Element IVec4 -> Element IVec4
f Int32
Element IVec4
y) (Element IVec4 -> Element IVec4
f Int32
Element IVec4
z) (Element IVec4 -> Element IVec4
f Int32
Element IVec4
w)
instance MonoPointed IVec4 where
opoint :: Element IVec4 -> IVec4
opoint Element IVec4
x = Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4 Int32
Element IVec4
x Int32
Element IVec4
x Int32
Element IVec4
x Int32
Element IVec4
x
instance Elementwise IVec4 where
{-# INLINE emap2 #-}
emap2 :: (Element IVec4 -> Element IVec4 -> Element IVec4)
-> IVec4 -> IVec4 -> IVec4
emap2 Element IVec4 -> Element IVec4 -> Element IVec4
f IVec4
p0 IVec4
p1 =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p0 \Int32
x0 Int32
y0 Int32
z0 Int32
w0 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p1 \Int32
x1 Int32
y1 Int32
z1 Int32
w1 ->
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4
(Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
x0 Int32
Element IVec4
x1)
(Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
y0 Int32
Element IVec4
y1)
(Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
z0 Int32
Element IVec4
z1)
(Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
w0 Int32
Element IVec4
w1)
{-# INLINE emap3 #-}
emap3 :: (Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4)
-> IVec4 -> IVec4 -> IVec4 -> IVec4
emap3 Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f IVec4
p0 IVec4
p1 IVec4
p2 =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p0 \Int32
x0 Int32
y0 Int32
z0 Int32
w0 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p1 \Int32
x1 Int32
y1 Int32
z1 Int32
w1 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p2 \Int32
x2 Int32
y2 Int32
z2 Int32
w2 ->
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4
(Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
x0 Int32
Element IVec4
x1 Int32
Element IVec4
x2)
(Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
y0 Int32
Element IVec4
y1 Int32
Element IVec4
y2)
(Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
z0 Int32
Element IVec4
z1 Int32
Element IVec4
z2)
(Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
w0 Int32
Element IVec4
w1 Int32
Element IVec4
w2)
{-# INLINE emap4 #-}
emap4 :: (Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4)
-> IVec4 -> IVec4 -> IVec4 -> IVec4 -> IVec4
emap4 Element IVec4
-> Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f IVec4
p0 IVec4
p1 IVec4
p2 IVec4
p3 =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p0 \Int32
x0 Int32
y0 Int32
z0 Int32
w0 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p1 \Int32
x1 Int32
y1 Int32
z1 Int32
w1 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p2 \Int32
x2 Int32
y2 Int32
z2 Int32
w2 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p3 \Int32
x3 Int32
y3 Int32
z3 Int32
w3 ->
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4
(Element IVec4
-> Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
x0 Int32
Element IVec4
x1 Int32
Element IVec4
x2 Int32
Element IVec4
x3)
(Element IVec4
-> Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
y0 Int32
Element IVec4
y1 Int32
Element IVec4
y2 Int32
Element IVec4
y3)
(Element IVec4
-> Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
z0 Int32
Element IVec4
z1 Int32
Element IVec4
z2 Int32
Element IVec4
z3)
(Element IVec4
-> Element IVec4 -> Element IVec4 -> Element IVec4 -> Element IVec4
f Int32
Element IVec4
w0 Int32
Element IVec4
w1 Int32
Element IVec4
w2 Int32
Element IVec4
w3)
{-# INLINE emap5 #-}
emap5 :: (Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4)
-> IVec4 -> IVec4 -> IVec4 -> IVec4 -> IVec4 -> IVec4
emap5 Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
f IVec4
p0 IVec4
p1 IVec4
p2 IVec4
p3 IVec4
p4 =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p0 \Int32
x0 Int32
y0 Int32
z0 Int32
w0 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p1 \Int32
x1 Int32
y1 Int32
z1 Int32
w1 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p2 \Int32
x2 Int32
y2 Int32
z2 Int32
w2 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p3 \Int32
x3 Int32
y3 Int32
z3 Int32
w3 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
p4 \Int32
x4 Int32
y4 Int32
z4 Int32
w4 ->
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4
(Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
f Int32
Element IVec4
x0 Int32
Element IVec4
x1 Int32
Element IVec4
x2 Int32
Element IVec4
x3 Int32
Element IVec4
x4)
(Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
f Int32
Element IVec4
y0 Int32
Element IVec4
y1 Int32
Element IVec4
y2 Int32
Element IVec4
y3 Int32
Element IVec4
y4)
(Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
f Int32
Element IVec4
z0 Int32
Element IVec4
z1 Int32
Element IVec4
z2 Int32
Element IVec4
z3 Int32
Element IVec4
z4)
(Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
-> Element IVec4
f Int32
Element IVec4
w0 Int32
Element IVec4
w1 Int32
Element IVec4
w2 Int32
Element IVec4
w3 Int32
Element IVec4
w4)
instance Num IVec4 where
{-# INLINE (+) #-}
IVec4 Int32
l1 Int32
l2 Int32
l3 Int32
l4 + :: IVec4 -> IVec4 -> IVec4
+ IVec4 Int32
r1 Int32
r2 Int32
r3 Int32
r4 =
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
IVec4
(Int32
l1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
r1)
(Int32
l2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
r2)
(Int32
l3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
r3)
(Int32
l4 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
r4)
{-# INLINE (-) #-}
IVec4 Int32
l1 Int32
l2 Int32
l3 Int32
l4 - :: IVec4 -> IVec4 -> IVec4
- IVec4 Int32
r1 Int32
r2 Int32
r3 Int32
r4 =
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
IVec4
(Int32
l1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
r1)
(Int32
l2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
r2)
(Int32
l3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
r3)
(Int32
l4 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
r4)
{-# INLINE (*) #-}
IVec4 Int32
l1 Int32
l2 Int32
l3 Int32
l4 * :: IVec4 -> IVec4 -> IVec4
* IVec4 Int32
r1 Int32
r2 Int32
r3 Int32
r4 =
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
IVec4
(Int32
l1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r1)
(Int32
l2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r2)
(Int32
l3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r3)
(Int32
l4 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
r4)
{-# INLINE abs #-}
abs :: IVec4 -> IVec4
abs IVec4
x = IVec4
x
{-# INLINE signum #-}
signum :: IVec4 -> IVec4
signum IVec4
v4 = IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IVec4) -> IVec4
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
v4 \Int32
a Int32
b Int32
c Int32
d ->
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4 (Int32 -> Int32
forall a. Num a => a -> a
signum Int32
a) (Int32 -> Int32
forall a. Num a => a -> a
signum Int32
b) (Int32 -> Int32
forall a. Num a => a -> a
signum Int32
c) (Int32 -> Int32
forall a. Num a => a -> a
signum Int32
d)
{-# INLINE fromInteger #-}
fromInteger :: Integer -> IVec4
fromInteger Integer
x = Int32 -> Int32 -> Int32 -> Int32 -> IVec4
IVec4 Int32
x' Int32
x' Int32
x' Int32
x'
where
x' :: Int32
x' = Integer -> Int32
forall a. Num a => Integer -> a
fromInteger Integer
x
instance Storable IVec4 where
{-# INLINE sizeOf #-}
sizeOf :: IVec4 -> Int
sizeOf IVec4
_ = Int
16
{-# INLINE alignment #-}
alignment :: IVec4 -> Int
alignment IVec4
_ = Int
8
{-# INLINE poke #-}
poke :: Ptr IVec4 -> IVec4 -> IO ()
poke Ptr IVec4
ptr IVec4
v4 =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> IO ()) -> IO ()
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
v4 \Int32
a Int32
b Int32
c Int32
d -> do
Ptr IVec4 -> Int -> Int32 -> IO ()
forall b. Ptr b -> Int -> Int32 -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr IVec4
ptr Int
0 Int32
a
Ptr IVec4 -> Int -> Int32 -> IO ()
forall b. Ptr b -> Int -> Int32 -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr IVec4
ptr Int
4 Int32
b
Ptr IVec4 -> Int -> Int32 -> IO ()
forall b. Ptr b -> Int -> Int32 -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr IVec4
ptr Int
8 Int32
c
Ptr IVec4 -> Int -> Int32 -> IO ()
forall b. Ptr b -> Int -> Int32 -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr IVec4
ptr Int
12 Int32
d
{-# INLINE peek #-}
peek :: Ptr IVec4 -> IO IVec4
peek Ptr IVec4
ptr = Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4
(Int32 -> Int32 -> Int32 -> Int32 -> IVec4)
-> IO Int32 -> IO (Int32 -> Int32 -> Int32 -> IVec4)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr IVec4 -> Int -> IO Int32
forall b. Ptr b -> Int -> IO Int32
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr IVec4
ptr Int
0
IO (Int32 -> Int32 -> Int32 -> IVec4)
-> IO Int32 -> IO (Int32 -> Int32 -> IVec4)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr IVec4 -> Int -> IO Int32
forall b. Ptr b -> Int -> IO Int32
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr IVec4
ptr Int
4
IO (Int32 -> Int32 -> IVec4) -> IO Int32 -> IO (Int32 -> IVec4)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr IVec4 -> Int -> IO Int32
forall b. Ptr b -> Int -> IO Int32
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr IVec4
ptr Int
8
IO (Int32 -> IVec4) -> IO Int32 -> IO IVec4
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr IVec4 -> Int -> IO Int32
forall b. Ptr b -> Int -> IO Int32
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr IVec4
ptr Int
12
instance Block IVec4 where
type PackedSize IVec4 = 16
alignment140 :: forall (proxy :: * -> *). proxy IVec4 -> Int
alignment140 proxy IVec4
_ = Int
16
sizeOf140 :: forall (proxy :: * -> *). proxy IVec4 -> Int
sizeOf140 proxy IVec4
_ = Int
16
alignment430 :: forall (proxy :: * -> *). proxy IVec4 -> Int
alignment430 = proxy IVec4 -> Int
forall b (proxy :: * -> *). Block b => proxy b -> Int
forall (proxy :: * -> *). proxy IVec4 -> Int
alignment140
sizeOf430 :: forall (proxy :: * -> *). proxy IVec4 -> Int
sizeOf430 = proxy IVec4 -> Int
forall b (proxy :: * -> *). Block b => proxy b -> Int
forall (proxy :: * -> *). proxy IVec4 -> Int
sizeOf140
isStruct :: forall (proxy :: * -> *). proxy IVec4 -> Bool
isStruct proxy IVec4
_ = Bool
False
read140 :: forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> m IVec4
read140 = Ptr a -> Diff a IVec4 -> m IVec4
forall (m :: * -> *) b a.
(MonadIO m, Storable b) =>
Ptr a -> Diff a b -> m b
peekDiffOff
write140 :: forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> IVec4 -> m ()
write140 = Ptr a -> Diff a IVec4 -> IVec4 -> m ()
forall (m :: * -> *) b a.
(MonadIO m, Storable b) =>
Ptr a -> Diff a b -> b -> m ()
pokeDiffOff
read430 :: forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> m IVec4
read430 = Ptr a -> Diff a IVec4 -> m IVec4
forall b (m :: * -> *) a.
(Block b, MonadIO m) =>
Ptr a -> Diff a b -> m b
forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> m IVec4
read140
write430 :: forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> IVec4 -> m ()
write430 = Ptr a -> Diff a IVec4 -> IVec4 -> m ()
forall b (m :: * -> *) a.
(Block b, MonadIO m) =>
Ptr a -> Diff a b -> b -> m ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> IVec4 -> m ()
write140
readPacked :: forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> m IVec4
readPacked = Ptr a -> Diff a IVec4 -> m IVec4
forall b (m :: * -> *) a.
(Block b, MonadIO m) =>
Ptr a -> Diff a b -> m b
forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> m IVec4
read140
writePacked :: forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> IVec4 -> m ()
writePacked = Ptr a -> Diff a IVec4 -> IVec4 -> m ()
forall b (m :: * -> *) a.
(Block b, MonadIO m) =>
Ptr a -> Diff a b -> b -> m ()
forall (m :: * -> *) a.
MonadIO m =>
Ptr a -> Diff a IVec4 -> IVec4 -> m ()
write140
{-# INLINE alignment140 #-}
{-# INLINE sizeOf140 #-}
{-# INLINE alignment430 #-}
{-# INLINE sizeOf430 #-}
{-# INLINE isStruct #-}
{-# INLINE read140 #-}
{-# INLINE write140 #-}
{-# INLINE read430 #-}
{-# INLINE write430 #-}
{-# INLINE readPacked #-}
{-# INLINE writePacked #-}
instance Ix IVec4 where
{-# INLINE range #-}
range :: (IVec4, IVec4) -> [IVec4]
range (IVec4
l, IVec4
u) =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> [IVec4]) -> [IVec4]
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
l \Int32
l1 Int32
l2 Int32
l3 Int32
l4 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> [IVec4]) -> [IVec4]
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
u \Int32
u1 Int32
u2 Int32
u3 Int32
u4 ->
Int32 -> Int32 -> Int32 -> Int32 -> IVec4
ivec4
(Int32 -> Int32 -> Int32 -> Int32 -> IVec4)
-> [Int32] -> [Int32 -> Int32 -> Int32 -> IVec4]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Int32, Int32) -> [Int32]
forall a. Ix a => (a, a) -> [a]
range (Int32
l1, Int32
u1)
[Int32 -> Int32 -> Int32 -> IVec4]
-> [Int32] -> [Int32 -> Int32 -> IVec4]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Int32, Int32) -> [Int32]
forall a. Ix a => (a, a) -> [a]
range (Int32
l2, Int32
u2)
[Int32 -> Int32 -> IVec4] -> [Int32] -> [Int32 -> IVec4]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Int32, Int32) -> [Int32]
forall a. Ix a => (a, a) -> [a]
range (Int32
l3, Int32
u3)
[Int32 -> IVec4] -> [Int32] -> [IVec4]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Int32, Int32) -> [Int32]
forall a. Ix a => (a, a) -> [a]
range (Int32
l4, Int32
u4)
{-# INLINE unsafeIndex #-}
unsafeIndex :: (IVec4, IVec4) -> IVec4 -> Int
unsafeIndex (IVec4
l, IVec4
u) IVec4
i =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> Int) -> Int
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
l \Int32
l1 Int32
l2 Int32
l3 Int32
l4 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> Int) -> Int
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
u \Int32
u1 Int32
u2 Int32
u3 Int32
u4 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> Int) -> Int
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
i \Int32
i1 Int32
i2 Int32
i3 Int32
i4 ->
(Int32, Int32) -> Int32 -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (Int32
l4, Int32
u4) Int32
i4 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (Int32, Int32) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (Int32
l4, Int32
u4) Int -> Int -> Int
forall a. Num a => a -> a -> a
* (
(Int32, Int32) -> Int32 -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (Int32
l3, Int32
u3) Int32
i3 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (Int32, Int32) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (Int32
l3, Int32
u3) Int -> Int -> Int
forall a. Num a => a -> a -> a
* (
(Int32, Int32) -> Int32 -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (Int32
l2, Int32
u2) Int32
i2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (Int32, Int32) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (Int32
l2, Int32
u2) Int -> Int -> Int
forall a. Num a => a -> a -> a
* (
(Int32, Int32) -> Int32 -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (Int32
l1, Int32
u1) Int32
i1)))
{-# INLINE inRange #-}
inRange :: (IVec4, IVec4) -> IVec4 -> Bool
inRange (IVec4
l, IVec4
u) IVec4
i =
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> Bool) -> Bool
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
l \Int32
l1 Int32
l2 Int32
l3 Int32
l4 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> Bool) -> Bool
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
u \Int32
u1 Int32
u2 Int32
u3 Int32
u4 ->
IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> Bool) -> Bool
forall r. IVec4 -> (Int32 -> Int32 -> Int32 -> Int32 -> r) -> r
withIVec4 IVec4
i \Int32
i1 Int32
i2 Int32
i3 Int32
i4 ->
(Int32, Int32) -> Int32 -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (Int32
l1, Int32
u1) Int32
i1 Bool -> Bool -> Bool
&&
(Int32, Int32) -> Int32 -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (Int32
l2, Int32
u2) Int32
i2 Bool -> Bool -> Bool
&&
(Int32, Int32) -> Int32 -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (Int32
l3, Int32
u3) Int32
i3 Bool -> Bool -> Bool
&&
(Int32, Int32) -> Int32 -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (Int32
l4, Int32
u4) Int32
i4