{-# LANGUAGE ForeignFunctionInterface #-}
 
module Language.ObjectiveC.Luka.Prelude where

import Foreign hiding (void)
import Foreign.C.Types
import Foreign.C.String

import Prelude ((-))
import Air.Env hiding ((-))
import Control.Monad ((>=>))

import Language.ObjectiveC.Luka.RunTime

import Foreign.LibFFI
import Data.ByteString (ByteString)

import Language.ObjectiveC.Luka.API

map_array :: (ID -> IO a) -> ID -> IO [a]
map_array f xs = do
  count <- xs.msg_cuint "count" []
  [0 .. count - 1].mapM (\i -> do
    object <- xs.msg_obj "objectAtIndex:" [argCUInt i]
    f object
    )
