module Chiphunk.Low.Internal where
import Foreign
import Foreign.C.Types
withList :: Storable a => [a] -> ((CInt, Ptr a) -> IO b) -> IO b
withList :: [a] -> ((CInt, Ptr a) -> IO b) -> IO b
withList [a]
xs (CInt, Ptr a) -> IO b
inner = [a] -> (Ptr a -> IO b) -> IO b
forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
withArray [a]
xs ((Ptr a -> IO b) -> IO b) -> (Ptr a -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr a
p -> (CInt, Ptr a) -> IO b
inner (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> Int -> CInt
forall a b. (a -> b) -> a -> b
$ [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs, Ptr a -> Ptr a
forall a b. Ptr a -> Ptr b
castPtr Ptr a
p)