Request: withArrayLength

Sven Panne Sven.Panne at aedion.de
Mon Mar 29 02:35:47 EST 2004


I wrote:
> [...] So if nobody yells, I'll add
> 
>    withArrayLen  :: Storable a =>      [a] -> (Ptr a -> Int -> IO b) -> IO b
>    withArrayLen0 :: Storable a => a -> [a] -> (Ptr a -> Int -> IO b) -> IO b
> [...]

After some thoughts, swapping the order of the pointer and the length, i.e.:

    withArrayLen  :: Storable a =>      [a] -> (Int -> Ptr a -> IO b) -> IO b
    withArrayLen0 :: Storable a => a -> [a] -> (Int -> Ptr a -> IO b) -> IO b

might be nicer, because then we had the nice property:

    withArrayLen x peekArray == x

Opinions?

Cheers,
    S.



More information about the FFI mailing list