module Mischief.ECS.Foreign where

import Control.Monad.IO.Class
import Foreign (Ptr, Storable)
import Foreign.Marshal.Alloc as A
import Mischief.ECS.World

alloca :: (Storable a) => (Ptr a -> System b) -> System b
alloca :: forall a b. Storable a => (Ptr a -> System b) -> System b
alloca Ptr a -> System b
s = do
  x <- System (System b -> IO b)
forall a. System (System a -> IO a)
sysUnliftIO
  liftIO $ A.alloca $ x . s