Export through FFI Haskell List to C array (by MarshalAlloc)

2004-11-09 Thread David Lo
Dear all, Anyone has ever tried exporting Haskell list to C array ? I read in the FFI for MarshalAlloc, it is mentioned that Haskell lists are typically passed as C arrays to C functions. However, how can we do that ? I have a list of Int (i.e. [Int]) which I would like to pass as int[] in C. Pl

Re: Export through FFI Haskell List to C array (by MarshalAlloc)

2004-11-09 Thread Peter Simons
David Lo writes: > Anyone has ever tried exporting Haskell list to C array? Check out the module Foreign.Marshal.Array, specifically the functions: withArray:: Storable a => [a] -> (Ptr a -> IO b) -> IO b withArrayLen :: Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b These will ma