Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Haskell FFI passing multiple arrays to C

Eddy JD:

I have a C function with type


int func(int len1, int *array1, int len2, int *array2);

that I'd like to call from Haskell. It doesn't modify its contents. I want to pass data from lists. I've been looking through Foreign.Marshal.Array, but I'm quite confused. Either newArray or withArray seems to do what I want, but withArray, for example, takes a function with type


Ptr a -> IO b

And I'm not quite sure how to deal with that given the two arrays in my function. So far, I have:


foreign import ccall unsafe "func.h func"
c_func :: CInt -> Ptr CInt -> CInt -> Ptr CInt -> IO CInt

And I'm not sure how to call this. In the documentation (http://ift.tt/2smTE4w), it just says to read Foreign.Marshall.Array.

Thanks!

Edit: typo.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Haskell FFI passing multiple arrays to C

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×