{-# OPTIONS_HADDOCK hide #-}
module Graphics.Rendering.OpenGL.GL.PeekPoke (
poke1, poke2, poke3, poke4,
peek1, peek2, peek3, peek4,
peek1M, peek2M, peek3M, peek4M
) where
import Foreign.Ptr
import Foreign.Storable
{-# INLINE poke1 #-}
poke1 :: Storable a => Ptr a -> a -> IO ()
poke1 :: forall a. Storable a => Ptr a -> a -> IO ()
poke1 Ptr a
ptr a
x =
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
0 a
x
{-# INLINE poke2 #-}
poke2 :: Storable a => Ptr a -> a -> a -> IO ()
poke2 :: forall a. Storable a => Ptr a -> a -> a -> IO ()
poke2 Ptr a
ptr a
x a
y = do
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
0 a
x
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
1 a
y
{-# INLINE poke3 #-}
poke3 :: Storable a => Ptr a -> a -> a -> a -> IO ()
poke3 :: forall a. Storable a => Ptr a -> a -> a -> a -> IO ()
poke3 Ptr a
ptr a
x a
y a
z = do
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
0 a
x
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
1 a
y
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
2 a
z
{-# INLINE poke4 #-}
poke4 :: Storable a => Ptr a -> a -> a -> a -> a -> IO ()
poke4 :: forall a. Storable a => Ptr a -> a -> a -> a -> a -> IO ()
poke4 Ptr a
ptr a
x a
y a
z a
w = do
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
0 a
x
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
1 a
y
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
2 a
z
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr Int
3 a
w
{-# INLINE peek1 #-}
peek1 :: Storable a => (a -> b) -> Ptr a -> IO b
peek1 :: forall a b. Storable a => (a -> b) -> Ptr a -> IO b
peek1 a -> b
f Ptr a
ptr = do
a
x <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
0
b -> IO b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> IO b) -> b -> IO b
forall a b. (a -> b) -> a -> b
$ a -> b
f a
x
{-# INLINE peek2 #-}
peek2 :: Storable a => (a -> a -> b) -> Ptr a -> IO b
peek2 :: forall a b. Storable a => (a -> a -> b) -> Ptr a -> IO b
peek2 a -> a -> b
f = (a -> a -> IO b) -> Ptr a -> IO b
forall a b. Storable a => (a -> a -> IO b) -> Ptr a -> IO b
peek2M ((a -> a -> IO b) -> Ptr a -> IO b)
-> (a -> a -> IO b) -> Ptr a -> IO b
forall a b. (a -> b) -> a -> b
$ \a
x a
y -> b -> IO b
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> a -> b
f a
x a
y)
{-# INLINE peek3 #-}
peek3 :: Storable a => (a -> a -> a -> b) -> Ptr a -> IO b
peek3 :: forall a b. Storable a => (a -> a -> a -> b) -> Ptr a -> IO b
peek3 a -> a -> a -> b
f = (a -> a -> a -> IO b) -> Ptr a -> IO b
forall a b. Storable a => (a -> a -> a -> IO b) -> Ptr a -> IO b
peek3M ((a -> a -> a -> IO b) -> Ptr a -> IO b)
-> (a -> a -> a -> IO b) -> Ptr a -> IO b
forall a b. (a -> b) -> a -> b
$ \a
x a
y a
z -> b -> IO b
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> a -> a -> b
f a
x a
y a
z)
{-# INLINE peek4 #-}
peek4 :: Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
peek4 :: forall a b. Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
peek4 a -> a -> a -> a -> b
f = (a -> a -> a -> a -> IO b) -> Ptr a -> IO b
forall a b.
Storable a =>
(a -> a -> a -> a -> IO b) -> Ptr a -> IO b
peek4M ((a -> a -> a -> a -> IO b) -> Ptr a -> IO b)
-> (a -> a -> a -> a -> IO b) -> Ptr a -> IO b
forall a b. (a -> b) -> a -> b
$ \a
x a
y a
z a
w -> b -> IO b
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> a -> a -> a -> b
f a
x a
y a
z a
w)
{-# INLINE peek1M #-}
peek1M :: Storable a => (a -> IO b) -> Ptr a -> IO b
peek1M :: forall a b. Storable a => (a -> IO b) -> Ptr a -> IO b
peek1M a -> IO b
f Ptr a
ptr = do
a
x <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
0
a -> IO b
f a
x
{-# INLINE peek2M #-}
peek2M :: Storable a => (a -> a -> IO b) -> Ptr a -> IO b
peek2M :: forall a b. Storable a => (a -> a -> IO b) -> Ptr a -> IO b
peek2M a -> a -> IO b
f Ptr a
ptr = do
a
x <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
0
a
y <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
1
a -> a -> IO b
f a
x a
y
{-# INLINE peek3M #-}
peek3M :: Storable a => (a -> a -> a -> IO b) -> Ptr a -> IO b
peek3M :: forall a b. Storable a => (a -> a -> a -> IO b) -> Ptr a -> IO b
peek3M a -> a -> a -> IO b
f Ptr a
ptr = do
a
x <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
0
a
y <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
1
a
z <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
2
a -> a -> a -> IO b
f a
x a
y a
z
{-# INLINE peek4M #-}
peek4M :: Storable a => (a -> a -> a -> a -> IO b) -> Ptr a -> IO b
peek4M :: forall a b.
Storable a =>
(a -> a -> a -> a -> IO b) -> Ptr a -> IO b
peek4M a -> a -> a -> a -> IO b
f Ptr a
ptr = do
a
x <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
0
a
y <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
1
a
z <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
2
a
w <- Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr Int
3
a -> a -> a -> a -> IO b
f a
x a
y a
z a
w