Marshal Haskell list into monolithic arrays

Hi all, There is a 'newArray' operation in MarshallArray to marshal Haskell list, with the definination of 'newArray :: Storable a => [a] -> IO (Ptr a)'. However, when I pass the 'Ptr a' to a C function, only the the first element of the list is available in C. Could anyone give some hints? The C function looks like: //////////////////// void lowPassFilter(float *fs[10], float *sum) { // Only *fs[0] is available here, why? } ////////////// with the import call in Haskell like this: foreign import ccall safe "lowPassFilter" lowPassFilter :: Ptr (CFloat) -> Ptr (CFloat) -> IO (()) Should I use ' lowPassFilter :: Ptr ([CFloat]) -> Ptr (CFloat) -> IO (())', and define 'float fs[10]' to be Storable in Haskell? Best wishes, Yours, Jun Direct: +46 8 790 4150 Fax: +46 8 751 1793 Post Address: KTH/IMIT/ LECS, Electrum 229, SE-164 40 Kista, Stockholm, Sweden Visiting address: Forum-Building, Isafjordsgatan 39, 8th floor, elevator C

On Thu, 2006-08-17 at 14:20 +0000, zhu Jun wrote:
Hi all,
There is a 'newArray' operation in MarshallArray to marshal Haskell list, with the definination of 'newArray :: Storable a => [a] -> IO (Ptr a)'. However, when I pass the 'Ptr a' to a C function, only the the first element of the list is available in C. Could anyone give some hints?
The C function looks like: //////////////////// void lowPassFilter(float *fs[10], float *sum) { // Only *fs[0] is available here, why? } ////////////// with the import call in Haskell like this: foreign import ccall safe "lowPassFilter" lowPassFilter :: Ptr (CFloat) -> Ptr (CFloat) -> IO (())
How are you calling this? Show us the code where you use lowPassFilter and newArray.
Should I use ' lowPassFilter :: Ptr ([CFloat]) -> Ptr (CFloat) -> IO (())', and define 'float fs[10]' to be Storable in Haskell?
No. Duncan
participants (2)
-
Duncan Coutts
-
zhu Jun