[C2hs] Marshal Haskell list into monolithic arrays

zhu Jun lilozhu at hotmail.com
Thu Aug 17 10:20:58 EDT 2006


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




More information about the C2hs mailing list