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
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