Can the FFI deal with arrays? If so, how?

后端 未结 4 1293
终归单人心
终归单人心 2021-01-01 14:37

I\'m pretty sure it\'s possible to send arrays through the FFI, but I can\'t find any examples. For instance, I have a Haskell array that I send to a int foo(int*)

4条回答
  •  旧巷少年郎
    2021-01-01 15:15

    To convert a FFI Ptr into a Haskell list, you can use:

    peekArray0 :: (Storable a, Eq a) => a -> Ptr a -> IO [a]
    

    http://hackage.haskell.org/packages/archive/base/4.2.0.1/doc/html/Foreign-Marshal-Array.html#v%3ApeekArray0

提交回复
热议问题