[C2hs] Marshal Haskell list into monolithic arrays
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Thu Aug 17 10:39:39 EDT 2006
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
More information about the C2hs
mailing list